Page 1 of 1

shift columns using regex

Posted: Wed Jan 30, 2013 3:18 am
by C0ppert0p
I want to be able to shift everything from position x to the end of the line , back to position x. using regex
This can be done with block mode; selecting everything after a certain position and then using the reduce indent button.

I have huge files that may have lines anywhere from 20 to 600 characters long. Selecting a 6,000 lines from a fixed position to the end of the longest line is problematic.

Thanks in advance

Posted: Thu Jan 31, 2013 12:59 am
by ak47wong
Your problem description is unclear. Can you please provide examples of the data before and after the change? Please enclose the data in

Code: Select all

[/color][/b]...[b][color=blue][/code ][/color][/b] tags to retain the whitespace and layout.

Posted: Thu Jan 31, 2013 8:52 pm
by C0ppert0p
Sure thing:

before

Code: Select all

data                               more data more data more data more data 
data                    more data more data more data more data more data more data more data more data  more data more data more data
data                                           more data more data more data more data more data more data more data more data
data                       more data more data more data more data more data more data more data more data more data more data more data more data more data more data
data                                                           more data more data more data more data more data more data more data more data
After:

Code: Select all

data                more data more data more data more data more data
data                more data more data more data more data more data more data more data more data more data more data more data
data                more data more data more data more data more data more data more data more data
data                more data more data more data more data more data more data more data more data more data more data more data more data more data more data
data                more data more data more data more data more data more data more data more data
There are over 6000 lines of this. All lines are variable in length; from as few as twenty to hundreds of characters.
There are many of these files

Posted: Thu Jan 31, 2013 10:03 pm
by ben_josephs
To use the Reduce indent command you don't need to select all the text to the right. Select a single character in the first line and extend the selection to the bottom of the file with the Select to end of document command (<Ctrl+Shift+End>).

Posted: Fri Feb 01, 2013 2:11 am
by ak47wong
If you want to use regular expressions, firstly enable POSIX regular expression syntax in Configure > Preferences > Editor.

Then, to always leave 16 spaces after data (where there are 16 or more spaces originally), perform a Replace operation as follows:

Find what: (data_{16})_*(.*) (replace the underscores with spaces)
Replace with: \1\2