VI Cheat Sheet

Here is a simple VI cheat sheet. I like ‘vi’ because it is pretty much included by default in everything. Just like in my Cisco life, I have always used the CLI and not GUIs because sometimes, those GUIs don’t work or they are not present. This way you can always be ready for anything that comes your way.


Scrolling and Searching

Command Function
<ctrl>d Scroll down (half a screen)
<ctrl>u Scroll up (half a screen)
<ctrl>f Page forward
<ctrl>b Page backward
/string Search forward
?string Search backward
<ctrl>l Redraw screen
<ctrl>g Display current line number and file information
n Repeat search
N Repeat search reverse G Go to last line
nG Go to line n
:n Go to line n
z<CR> Reposition window: cursor at top
z. Reposition window: cursor in middle
z- Reposition window: cursor at bottom

Delete Commands

Command Function
dd or ndd Delete n lines to general buffer
dw Delete word to general buffer
dnw Delete n words
d) Delete to end of sentence
db Delete previous word
D Delete to end of line
x Delete character

Undo Commands
Command Function
u Undo last change
U Undo all changes made to the line

Copy / Paste

Command Function
v Select Charecters
V Select the entire Line
d Delete (AKA Cut)
y Yank (AKA Copy)
P Paste before the cursor
p Paste afer the cursor

Share

Leave a Reply

Your email address will not be published. Required fields are marked *