Tip 30: Word Count in vi
You can execute shell commands from vi by typing ! [shell command]. To count the number of words in the current document run the wc (word count) program as a shell command in vi and specify % as the wc argument. The % references the current open file in vi. The file must be saved for this to work otherwise, a file not found exception is returned.
To use the result of any shell output command use the :r! instead of the ! before the shell command. This will append the output of the command to the end of the current open file.
Sources: Vim tips: Working with external commands
Logon
Fill out the form below to logon to this site, or sign up below.
Signup
Fill out the form below to join as a member of this site.
