Learning the vi Editor

Learning the vi EditorSearch this book
Previous: 3.1 Movement by Screens Chapter 3
Moving Around in a Hurry
Next: 3.3 Movement by Searches
 

3.2 Movement by Text Blocks

[e] Another way that you can think of moving through a vi file is by text blocks - words, sentences, paragraphs, or sections. You have already learned to move forward and backward by word (w, W, b or B). In addition, you can use these commands:

e

Move to end of word.

E

Move to end of word (ignore punctuation).

(

Move to beginning of current sentence.

)

Move to beginning of next sentence.

{

Move to beginning of current paragraph.

}

Move to beginning of next paragraph.

[[

Move to beginning of current section.

]]

Move to beginning of next section.

To find the end of a sentence, vi looks for one of the punctuation marks ? . !. vi locates the end of a sentence when the punctuation is followed by at least two spaces or when it appears as the last nonblank character on a line. If you have left only a single space following a period, or if the sentence ends with a quotation mark, vi won't recognize the sentence.

A paragraph is defined as text up to the next blank line, or up to one of the default paragraph macros (.IP, .PP, .LP, or .QP) from the nroff/troff ms macro package. Similarly, a section is defined as text up to the next default section macro (.NH, .SH, .H 1, .HU). The macros that are recognized as paragraph or section separators can be customized with the :set command, as described in Chapter 7, Advanced Editing .

Remember that you can combine numbers with movement. For example, 3) moves ahead three sentences. Also remember that you can edit using movement commands: d) deletes to the end of the current sentence, 2y} copies (yanks) two paragraphs ahead.


Previous: 3.1 Movement by Screens Learning the vi EditorNext: 3.3 Movement by Searches
3.1 Movement by Screens Book Index3.3 Movement by Searches

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System