VI Cheat Sheet
— Coding — 1 min read
This is a quick reference to using VI professionally. VI is a popular text editor that comes built-in on most unix based operating systems.
Create a new file and open it
vi <newfilename.txt>
Open an existing filename
vi <existingfilename.txt>
Switch to edit mode
Press i
to insert before current character
Press a
to insert after current character
Press O
to start a new line below current line
Switch to command mode
Press Esc
to switch back to command mode
Basic commands
x
- Delete a characterdd
- Delete a liner
- Replace a characterR
- Overwrite text, press<Esc>
to end:set nu
- Display line numbers:wq!
- Save and quit:q!
- Quite
- Move to end of current word$
- Move to end of current line^
- Move to beginning of current line+
- Move to beginning of next line-
- Move to beginning of previous lineG
- Go to last line of the file:n
- Go to line n (:10 for line 10)u
- Undo last single change~
- Change letter's caseyy
- Copy the current line6yy
- Copy six lines from current lineP
- Paste the text after the cursor position/text
- Search down for 'text'?text
- Search up for 'text'n
- Toggle through search results