



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A vi cheat sheet for opening, editing, and closing files, as well as various editing commands, movements, and searches. It also includes exercises for practicing these skills. Useful for Linux system administration students or anyone looking to learn vi text editor.
Typology: Summaries
1 / 5
This page cannot be seen from the preview
Don't miss anything!




vi filename (fn=filename) vi -r filename Recover a file from a crashed session vi + filename Place the cursor on last line of file. vi +n filename Place the cursor on line "n" of file. vi +/pat filename Place cursor on line with first occurrence of "pat"tern
:w Write the file to disk. Don't exit. :w! Write the file to disk even if read/only. :wq Write the file to disk and exit. :wq! Write the file to disk even if read/only and quit. :q Quit the file (only if no changes). :q! Quite the file even if changes.
A Move to end of line, change to insert mode. h Move 1 space backwards (back/left arrow). j Move down 1 line (down arrow). k Move up 1 line (up arrow). l Move 1 space forwards (forward/right arrow) w Move cursor to start of next word. W Same as "w". b Move cursor to start of previous word. B Same as "b". :n Go to line number "n" in the file.
i Enter in to input mode. o Add a line below cursor and enter in to input mode. x Delete character (del key in some cases). D Delete line from right of cursor to end of line. dd Delete entire line. u Undo last edit or restore current line. p Put yanked text before the cursor. yy Yank current line.
/pattern Search for "pattern" in the file going forwards. ?pattern Search for "pattern" in the file going backwards. n Find the next occurrence of pattern found forwards. N Find next occurrence of pattern found backwards.
nyyp Copy n lines to buffer, paste below cursor nyyP Copy n lines to buffer, paste above cursor nddp Cut n lines and copy to buffer, paste below cursor nddP Cut n lines and copy to buffer, paste above cursor
$ cd $ vi temp.txt
VI is great! I think I'll be using vi from now on instead of Word I like VI!
Search and replace
:%s/GNU/COW/gc
/kernel SHIFT-A "some text"
:q!
Practice, Practice, Practice!
$ cd $ vi COPYING
Repeat the exercises above using another editor