Re-ordering Columns in a Text File
Yes this is possible within vanilla Notepad++
, though as noted there are also plugins that will do it. A better (more robust) approach might be to use some command-line text-processing tools, but if you need a quick-and-dirty solution you can find that below:
Assuming your exact input (col1|col2|col3
, pipe delimeter, no pipe in col2
):
Find: (.*?)\|(.*?)\|(.*)
Replace: \1|\3|\2
works for me here in Notepad++
, built Jan 2015. Somewhat brutish, but it works.
Explanation:
.*
- matches any character (except newline), between zero and unlimited times
.*?
- matches any character (except newline) as above, in a non-greedy manner (ie match as little as possible)
(.*)
- plain brackets denote capturing group of above (to use in Replace as eg \1
, \2
, \3
etc )
\|
- \
escapes pipe (|
) to match it literally
\1|\3|\2
- print 1st matching group, pipe, third matching group, pipe, second matching group
I just found this, which I didn't even know before but looks super useful: Edit columns in Notepad++ with TextFX plugin
– MC10 – 2015-08-03T01:12:28.217I would not call this "repositioning lines". – Lightness Races with Monica – 2015-08-03T12:46:52.660