Page 1 of 1
Tab Insert Questions
Posted: Thu Mar 09, 2006 7:57 pm
by sysadmin
How do I insert tabs at various positions in each line of the file: 27, 36, 50, 61, 66, 72, 81, 93, 102, 110, 122
???
Thanks in advance!
Posted: Thu Mar 09, 2006 10:37 pm
by talleyrand
Two options.
The first is Block Select Mode. Enable that, go to those columns, highlight the entire column and hit Tab.
The second is via regular expressions. The following expression, where N is any of your numbers (27, 36, etc), could also be run.
Quote:
Find what: ^.{N-1}
Replace with: \0\t
[X] Regular expression
This assumes you are using Posix regular expression syntax:
Quote:
Configuration | Preferences | Editor
[X] Use POSIX regular expression syntax
And one of the regex gurus might offer a different route since as I think about it, that might do funny things with pre-existing tabs.
Posted: Thu Mar 09, 2006 11:07 pm
by sysadmin
Thank you, but I don't know how to enter the sequence in find and replace: ^.{27-1},???
27, 36, 50, 61, 66, 72, 81, 93, 102, 110, 122
Posted: Thu Mar 09, 2006 11:51 pm
by talleyrand
Pass #1
Find what: ^.{26}
Replace with: \0\t
Pass #2
Find what: ^.{35}
Replace with: \0\t
etc
The other option would be a one pass deal
Find what: (^.{26})(.{9})(.{14})
Replace with: (\1)\t(\2)\t(\3)
Continue the above find what pattern like (.{}) where the value inside {} is the next position minus the current position, e.g. 50-36 = 14 in the above example
On the replace portion, you will add \t(\NUMBER) where NUMBER is the count of tagged search expressions. Basically, repeat the pattern (\1)\t(\2)\t(\3)\t(\4) for each set of parenthesis you have in your search expression.
The help file under regular expressions can help explain far better about what you are attempting to do.