Re:Vim Recipes
by Dobbs on Wednesday May 20, 2009 @05:36AM
(#618292)
Something I recently learned that is really cool:
:<area>!<command>
will export the <area> to <comand> and then replace <area> with the output of the <command>. So you can do:
:%!sort # Sort the entire file.
:.!awk '{ print $1 }' # Replace the current line with the
first word/column.
So much power with this really simple set of commands. You can also highlight the an area using visual mode, and then just type ':!<command>' and it will autofill in the area for you.
:<area>!<command>
will export the <area> to <comand> and then replace <area> with the output of the <command>. So you can do:
:%!sort # Sort the entire file.
:.!awk '{ print $1 }' # Replace the current line with the first word/column.
So much power with this really simple set of commands. You can also highlight the an area using visual mode, and then just type ':!<command>' and it will autofill in the area for you.