Community
    • Login

    Columns++, I'd like to *retain* commas when converting to elastic tabs/spaces

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    3 Posts 2 Posters 34 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W PongW
      W Pong
      last edited by

      Greetings –

      I’m doing work in matlab where I frequently clean up legacy scripts involving array definitions. Syntax is

      myArray = {
      a,bbb,c,ddddd;
      e,ff,ggg,h;
      iiii,jj,k,l
      }
      In-house convention is to align the comma-separated array-elements into columns with spaces, while retaining the commas, as required by matlab syntax. Array element names can vary in length greatly, and files can get visually messy over time as different users edit and don’t re-align columns.

      What I typically do:

      (comma separated) --> convert separated values to tabs --> (elastic tabstops) --> convert tabs to spaces

      This is wonderfully quick and easy, but it removes the commas. I’ve played around but haven’t discovered – Is there a way to retain the commas?

      W PongW 1 Reply Last reply Reply Quote 1
      • W PongW
        W Pong @W Pong
        last edited by

        I should add that my current workaround is to highlight the affected region and do an ‘extended’ find replace, replacing “\t” with “,\t”. This works fine. Was just hoping I could avoid this need…

        CoisesC 1 Reply Last reply Reply Quote 2
        • CoisesC
          Coises @W Pong
          last edited by

          @W-Pong said in Columns++, I'd like to *retain* commas when converting to elastic tabs/spaces:

          I should add that my current workaround is to highlight the affected region and do an ‘extended’ find replace, replacing “\t” with “,\t”. This works fine. Was just hoping I could avoid this need…

          If you never have commas within quoted strings in your arrays, just use a slightly modified version of your work-around: without doing any conversion first, replace , with ,\t.

          If you do sometimes have commas in quoted strings, you can either do what you’re doing now or devise a regular expression replacement that will skip commas within quoted strings.

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors