|
|
You can send some or all of the contents of the current file through a program that acts as a filter, transforming the contents of the current file. For example, to use the tr command to translate the current paragraph into uppercase:
In general, you can use any filter in this way:
! movement filter <Enter>
An exclamation point typed in command mode introduces a filter command. movement is a vi command to move the cursor to the end of the block of text you want to feed through filter. The cursor jumps to the bottom line of the screen when you enter the movement command, and a ``!'' prompt appears; vi waits for you to enter the filter command and press <Enter>. Note that the cursor movement must refer to a block of text larger than one word; the commands w and e are not acceptable cursor movements.
Another common usage is to spell-check a sentence using spell, and replace it with a list of all the unidentified words it contains:
When looking for occurences of spelling mistakesApplying the above procedure replaces this sentence with the following:
occurencesThe escape filter can be used with any command that reads from the standard input. For example, use wc to find the number of words in a file; go to the top of the document and issue the command !Gwc -w. The document is replaced by a word count. Press u to get your document back again.