Learning the vi Editor

Learning the vi EditorSearch this book
Previous: 2.5 Joining Two Lines with J Chapter 2
Simple Editing
Next: 3. Moving Around in a Hurry
 

2.6 Review of Basic vi Commands

Table 2.1 presents a few of the commands you can perform by combining the commands c, d, and y with various text objects. The last two rows show additional commands for editing. Table 2.2 and Table 2.3 lists some other basic commands.

Table 2.1: Edit Commands
Text ObjectChangeDeleteCopy
1 wordcwdwyw

2 words, not counting punctuation

2cW or c2W2dW or d2W2yW or y2W
3 words back3cb or c3b3db or d3b3yb or y3b
1 lineccddyy or Y
to end of linec$ or Cd$ or Dy$
to beginning of linec0d0y0
single characterrx or Xyl or yh
five characters5s5x5yl
Table 2.2: Movement
MovementCommands
<-,-v,-^, ->

h, j, k, l

forward by wordw or W
backward by wordb or B
to end of line$
to beginning of line0
Table 2.3: Other Operations
OperationsCommands
place text from bufferP or p
start vi, open file if specifiedvi file
save edits, quit fileZZ
no saving of edits, quit file:q!

You can get by in vi using only the commands listed in Table 2.1, Table 2.2, and Table 2.3. However, in order to harness the real power of vi (and increase your own productivity), you will need more tools. The following chapters describe those tools.


Previous: 2.5 Joining Two Lines with J Learning the vi EditorNext: 3. Moving Around in a Hurry
2.5 Joining Two Lines with J Book Index3. Moving Around in a Hurry

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