This link has been bookmarked by 7 people . It was first bookmarked on 24 Mar 2008, by harry palmer.
-
20 Dec 08
-
17 Jun 08
-
Vim tips: Working with external commands
By Joe 'Zonker' Brockmeier on October 25, 2006 (8:00:00 AM)<!-- ADDTHIS BUTTON BEGIN --> <script type="text/javascript"> addthis_pub = 'linuxcom'; addthis_logo = 'http://c.fsdn.com/lc/images/lc_logo.png'; addthis_brand = 'Linux.com'; addthis_options = 'email, slashdot, digg, delicious, more'; </script>
Share <script src="http://s7.addthis.com/js/152/addthis_widget.js" type="text/javascript"></script> <!-- ADDTHIS BUTTON END -->
Print
Comments Vim is a powerful editing tool, but there are some things it just can't do. However, Vim lets you access shell commands and utilities without leaving Vim, and that lets you perform some amazing tricks.If you run
:shellor just:shwhile you're in the editor, Vim (or Gvim, if you're partial to Vim's GUI) will place you in an interactive shell. You can run whatever commands you want, and resume your Vim session by exiting the shell.As most other *nix applications, you can also pause Vim with
Ctrl-z, which will drop you back to the shell. When you're finished, you can resume Vim withfg. (This is a feature of the shell, not a Vim feature.)Have you ever started editing a file, made a bunch of changes, and then typed
:wto write your changes, only to find that the file is read-only? You can deal with that in a couple of ways, but one of the easiest things to do is to invoke a shell from within Vim and change the file's permissions before you save it again.Bang!
Vim also allows you to execute a command directly from the editor, without needing to drop to a shell, by using bang (
!) followed by the command to be run. For instance, if you're editing a file in Vim and want to find out how many words are in the file, run:! wc %
-
-
13 Oct 07
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.