Tuesday, March 25, 2008

Piping Buffers

Say you have a buffer in Vim, and you want to run it through an external command. For the sake of example, let's say that command is sort. All you have to do is the following:

:% ! sort

or more generally

:% ! command

If you want to bring the output of a command into buffer you can do:

:r ! ls -l

or even:

:r ! cat filename | sort

No comments: