Columns++, I'd like to *retain* commas when converting to elastic tabs/spaces
-
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?
-
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…
-
@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.