Show Menu
Cheatography

Basic Vim Cheat Sheet by

Basic Vim sheet for beginners

Modes

ESC
Command mode, toggles modes when in insert or visual mode
i
insert mode
v
Visual mode, start highli­ghting characters
V
Visual mode, start highli­ghting lines

Shell Command

:shell
Opens command prompt
exit
Exits command prompt

Files

:e filename
Open a new file
:w filename
Save changes to a file
:q
Exit Vim. If there is unsaved files, Vim will not exit
:q!
Exit Vim wihout saving changes
:x or zz
Exits Vim and saves changes to the file if changes were made

Undo and Redo

u
Undo last action
U
Undo all the latest changes that were made to the line
Ctrl+r
Redo

Open up new lines

o
Open new line BELOW the cursor
O
Open new line ABOVE the cursor

Tabs

:tabnew
Opens a new tab
gt
go to next tab
gT
Go to previous tab
:tabmove n
Move tab to position n
:tabc
Close tab
 

Yank (Copy), Delete (Cut) and Put (Paste)

yy
Yank the current line
:y
Yank the current line
y
Yank the highli­ghted text
:d or dd
Delete current line
D
Delete to the end of the line
d
Delete the highli­ghted text
dw
Delete word
dl
Delete character at cursor position
p
Put text after cursor position, put lines below current line
P
Put text before cursor position, put lines above current line
x
Delete current character

Windows

:split or :sp
Splits the current window horizo­ntally
:vsplit or :vs
Split the current window vertically
:split file
Opens the file in a second window
:n split file
Opens a new window n lines high
:new
Opens a new window horizo­ntally
:vnew
Opens a new window Vertically
:res n
Resizes window to n line size, if n is not provided window is resized to max size
CTRL-ww
Switches cursor between windows
CTRL-w <motion key>
Switches cursor between windows in motion key direction
CTRL-wn
Splits a window and starts editing a new file
CTRL-w r
Rotate windows positions
CTRL-w q or :q
Close window
 

Moving Around

h or left
Move LEFT one character
j or down
Move DOWN one line
k or up
Move UP one line
l or right
Move RIGHT one line
H
Move to the FIRST line of the screen
M
Move to the MIDDLE line of the screen
L
Move to the LAST line of the screen
b
Move to the BEGINNING of the word
B
Move to the BEGINNING of a blank delimited word
e
Move to the END of the word
E
Move to the END of black delimited word
w
Move to the NEXT word
W
Move to the NEXT blank delimited word
:n
Jump to line n (jump to line 42->:42)
To move up 9 lines type: 9k

Buffers

:buffers
find list of buffers
:b number
Select buffer number
:sb number
Splits the window and starts editing the buffer
:vertical sbuffer number
Splits the window vertically and edits the buffer
:bnext or :bn
Go to the next buffer
:bdelete
Deletes a buffer without saving
--Buffer Flags--
- Inactive buffer
h Hidden buffer
% Current buffer
# Alternate buffer
+ File has been modified
                               
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          VI Editor Cheat Sheet
          Sublime Text 3 - The Beginner's Guide Cheat Sheet
          Spacemacs (+Clojure) Keyboard Shortcuts

          More Cheat Sheets by Zoltan