vi and shell editing
I use vi for editing my httpd.conf and other config files as well as for some c programming and shell programming. One of the things I never really used well was the interaction with the shell inside of vi. If you are like me and quit vi to do some shell commands and then reopen your vi file you may want to just use :! to run a command right inside of vi. After you issue your command and get the standard input from the command it will prompt you to hit enter to go back to your vi editting. If you need to run more than one shell in the midst of your vi edit, use :sh.
I’ve found Bill Joy’s vi paper to be the best source of vi information on the web: vi paper
May 13th, 2005 at 1:50 am
Also keep in mind that:
!!command
(with NO COLON in front) will replace the current line with the output of the shell command “command”.
Additionally, you can pass text to your command, have it filter it, and replace the text with the filtered output. For example, you might want to send a paragraph to the fmt command:
!}fmt
This will use fmt to format the paragraph (note that using gqap is probably a better solution for this particular example, but it’s just an example).