> With the cursor on the line I can do this with the command
>
> :.s/\(\[^\|\]*\)\(|\)\(\[^\|\]*\)\(|\)\(.*\)/\3\2\1\4\5/
>
> which looks like a diagram for the cutting edge of
> a tunnelling machine.
While you've gotten other good suggestions, I do this sort of
thing on a regular basis and so will add my tip to others: my
biggest tip is using the command-line history window[1]. I'll
define and yank a single "column definition" ("\([^|]*\)|"). I
then repeatedly paste it into my command-line for as many columns
as I care about, building my replacement accordingly. Because my
input files often vary widely in column-count and column-order, a
single mapping/abbr doesn't really cut it[2] for me because
they're almost never reusable. This saves me from going nuts.
-tim
[1]
:help cmdwin
[2] /me likes your "tunnelling machine" quip
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---