Vim Commands Cheat Sheet

vim-command-cheat-sheet

Vim is a powerful and popular text editor that runs on the command line. Using Vim you will navigate around on screen with a keyboard instead of a mouse. It has a steep learning curve, but it can greatly improve your productivity once you master it. Here are some basic Vim commands to help you get started:

 

Frequently used commands :

 

i  –   insert before the cursor

gg  –   move cursor to the top of page

Esc  –   exit insert mode

yy  –   yank (copy) a line

: number  –   show line number

p  –    (paste) the clipboard after the cursor

/pattern  –   search for pattern

:q  –   quit (fails if there are unsaved changes)

n  –   repeat search in same direction

:wq   or  : x  or   ZZ  –  write (save) and quit

$  –   move cursor to end of line

:w  –   write (save) the file, but don’t exit

GG  –   move cursor to bottom of page

 

 
 
commands to move the cursor:
 

h –   move cursor left

 

L  –   move to bottom of screen

 

j –   move cursor down

 

w  –   jump forwards to the start of a word

 

k  –   move cursor up

 

W  –   jump forwards to the start of a word (words can contain punctuation)

 

l  –   move cursor right

 

e  –   jump forwards to the end of a word

 

gj  –   move cursor down (multi-line text)

 

E  –   jump forwards to the end of a word (words can contain punctuation)

gk  –   move cursor up (multi-line text)

 

b  –   jump backwards to the start of a word

 

H  –   move to top of screen

 

B  –   jump backwards to the start of a word (words can contain punctuation)

 

M  –   move to middle of screen

 

 
commands for Editing:
 

r –   replace a single character.

 

s  –    delete character and substitute text

 

R –   replace more than one character, until ESC is pressed.

 

S  –    delete line and substitute text (same as cc)

 

J –   join line below to the current one with one space in between

 

xp  –   transpose two letters (delete and paste)

 

gJ –   join line below to the current one without space in between

 

u  –   undo

 

cc  –    change (replace) entire line

 

U  –   restore (undo) last changed line

 

c$ or C –    change (replace) to the end of the line

 

Ctrl + r –    redo

 

ciw  –    change (replace) entire word

 .  –    repeat last command

 

cw or ce –    change (replace) to the end of the word

 

 

 
commands for saving and exiting:
 

:w  –   write (save) the file, but don’t exit

 

:q  –    quit (fails if there are unsaved changes)

 

:w !sudo tee %  –    write out the current file using sudo

 

:q!  or   ZQ  –    quit and throw away unsaved changes

 

:wq  or  : x or ZZ  –   write (save) and quit

 

:wqa  –    write (save) and quit on all tabs

 

 
command for search and replace:
 

/pattern  –   search for pattern

 

n  –   repeat search in same direction

 

?pattern  –   search backward for pattern

 

N  –   repeat search in opposite direction

 

 

commands for cut and paste:
 

yy  –   yank (copy) a line

 

y$   or   Y  –   yank (copy) to end of line

 

2yy  –   yank (copy) 2 lines

 

p  –    put (paste) the clipboard after cursor

 

yw  –   yank (copy) the characters of the word from the cursor position to the start of the next word

 

P  –   put (paste) before cursor

 

yiw  –   yank (copy) word under the cursor

 

dd  –   delete (cut) a line

 
 

 

Visual commands:
 

>  –    shift text right

 

~  –    switch case

 

<  –   shift text left

 

u  –   change marked text to lowercase

 

y  –    yank (copy) marked text

 

U  –   change marked text to uppercase

 

d  –    delete marked text

 

 

🎓 FREE Software Testing Fundamentals

14+ Hours of Premium Content

Master the fundamentals of software testing with our comprehensive free course. Perfect for beginners and those looking to strengthen their testing skills.

What You'll Learn
✓
Testing Basics
Test cases, bug reporting & more
✓
SQL & Database Testing
Query databases and test data integrity
✓
API Testing
Test REST APIs and endpoints
✓
JIRA
Manage bugs and track issues
Start Learning Free

100% Free • No Credit Card Required