You are on page 1of 1

Essential Vi Commands The following table lists useful vi commands for the beginner.

Mastering these commands will bring you to the 80% level of being an expert text editor. Note that the character sequence t, for example, is generated by holding down the Control key and tapping the t key. Basic Edit Mode Commands dw 3dw dW cw cW x s rf D C << >> % o O i I a A R . delete word delete word delete big word change word change big word delete char substitute char replace char big delete big change shift left shift right jump to match open line open line before insert big insert append big append replace characters repeat command deletes to end-of-word [for example] deletes three words deletes until next whitespace - can take a count like 3dW like dw, but starts insert mode - can take a count like dW, but starts insert mode - can take a count deletes current character - can take a count like x, but starts insert mode - can take a count [for example] replaces current character with f - can take a count deletes to end of line like D, but starts insert mode shift current line to the left shift current line to the right jumps to matching parenthesis, brace, or bracket adds a blank line after current line and starts insert mode adds a blank line before current line and starts insert mode starts insert mode before the current character starts insert mode at the beginning of the current line starts insert mode after the current character starts insert mode after the last character in the current line like i but with original characters replaced repeat the last edit command Searching /x /xy /\ <xy /xy\ > n N search search search word search word repeat search reverse repeat search [for example] search for the character x [for example] search for the character sequence xy [for example] search for word beginning with the sequence xy [for example] search for word ending with the sequence xy repeat the last search the last search in the opposite direction Copying and Setting Marks yy 3yy p P mq yq dq cq y% ytz yfz yank line yank lines put after put before mark a line yank to mark delete to mark change to mark yank to match yank to char yank to char inclusive copy the current line [for example] copy three lines put the last copy or deletion after the current character/line put the last copy or deletion before the current character/line [for example] mark the current line, naming it q [for example] copy from the current line to the line marked q [for example] like y q but deletes the lines [for example] like d q but then starts insert mode copies to matching parenthesis, brace, or bracket - also d% and c% [for example] copy until the rst occurrence of z - also dtz and ctz [for example] like ytz but includes z - also dfz and cfz While in Insert Mode ^d ^t shift left shift right shift the current line to the left shift the current line to the right Ed Commands :%s/ab/xy/g :%s/ab/xy/ global replace global replace [for example] replace each occurrence of ab with xy [for example] replace rst occurrence of ab with xy on each line

You might also like