Fork me on GitHub

article

Tasty VIM Morsel

September 26, 2006 | Computers | Leave a comment

I just learned a nice little bit on using VIM and feel the need to share.

When using vim you can insert the contents of command line output by using the :r! command.

For example:

:r! ls /etc/httpd

would insert the directory list of the /etc/httpd directory.

:r! cat file.txt

would insert the contents of file.txt and insert it into the current file.

:r! man cd | col -b

would insert a clean verson of the MAN page for the cd command. Col -b is needed to strip special line breaks that man pages contain.

:r! php file.php

would insert the output of the PHP script into the current file.

I can probably stop providing examples now. Handy freakin’ dandy! I dig it.

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Have your say:

Some HTML is OK

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

or, reply to this post via trackback.