Execute command-line statements from within the vi editor
It is very simple and occasionally useful to access the power of the shell from within your vim text editor. In normal mode (esc from insert mode), simply type, colon included
:r
Commands must be preceded by a bang symbol (exclamation mark). Some examples:
:r !date
Personally, i'll find this useful simply for putting in paths from the file system that i may not be certain of but that bash's tab autocomplete will be able to verify for me.
:r !echo /var/local
In UNIX, everything is a file, so what :r is doing is returning the output of the file created by a command (the standard output). This is just to mention that we can stick a file into our document directly.
:r ~/tmp/id_rsa.pub
That inserts the contents of the id_rsa.pub file right where you have your cursor in the document in vi normal mode.
Reference
http://princ3.wordpress.com/2007/08/27/insert-current-date-in-vim/
More like this
- Making Drupal nids into edit link from your command-line SQL
- Unscientificall confirmed command-line advice: leave slash off folder you are moving
- Indent lines in Vim
- Using Drush 3.1 by installing it in your local user directory
- Create rewrite rules from new and old URLs using the power of Vim to munge text


Comments
Post new comment