Vim Keyboard Shortcuts Cheatsheet

By | March 7, 2019

If you need to know Keyboard Shortcuts in Vim editor this program is a command-line based tool that’s is an improved version of the venerable vi editor program for Unix. Vim editor is Develop for use both from a command-line software and as a stand-alone application in a visual user interface, familiarity with Vim will help every Linux user — from an experienced system administrator to a newbie Raspberry Pi user.

this program light-weight editor helps text editing and advanced features such as find and cursor position histories, syntax highlighting, trans-session command, multiple level, and branching undo/redo history which can persist across editing sessions, and visual mode.

Linux uses a lot of configuration files, you’ll often need to edit them and vim is a great tool to do so
Vim is free and open-source software and is powerful. In the hands of an experienced operator, when using Vim, there are two main modes: the command mode and the other modes.

The command mode lets you select the working mode that you want to enter. Available modes are: save, quit, copy, paste and that kind of things but you can’t edit the file in the command mode directly. This is what many users that are new to vim puzzles and one has to get used to first.

This a cheatsheet to help you get the most out of vim keyboard shortcuts.
vim keyboard shortcut cheatsheet

Shortcut KeysFunction
Main
Escape keyGets out of the current mode into the “command mode”. All keys are bound of commands.
i“Insert mode” for inserting text. Keys behave as expected.
:“Last-line mode” where Vim expects you to enter a command such as to save the document.
Navigation keys
hmoves the cursor one character to the left.
j or Ctrl + Jmoves the cursor down one line.
k or Ctrl + Pmoves the cursor up one line.
lmoves the cursor one character to the right.
0moves the cursor to the beginning of the line.
$moves the cursor to the end of the line.
^moves the cursor to the first non-empty character of the line
wmove forward one word (next alphanumeric word)
Wmove forward one word (delimited by a white space)
5wmove forward five words
bmove backward one word (previous alphanumeric word)
Bmove backward one word (delimited by a white space)
5bmove backward five words
Gmove to the end of the file
ggmove to the beginning of the file.
Navigate around the document
(jumps to the previous sentence
)jumps to the next sentence
{jumps to the previous paragraph
}jumps to the next paragraph
[[jumps to the previous section
]]jumps to the next section
[]jump to the end of the previous section
][jump to the end of the next section
Insert text
aInsert text after the cursor
AInsert text at the end of the line
iInsert text before the cursor
oBegin a new line below the cursor
OBegin a new line above the cursor
Special inserts
:r [filename]Insert the file [filename] below the cursor
:r ![command]Execute [command] and insert its output below the cursor
Delete text
xdelete character at cursor
dwdelete a word.
d0delete to the beginning of a line.
d$delete to the end of a line.
d)delete to the end of sentence.
dggdelete to the beginning of the file.
dGdelete to the end of the file.
dddelete line
3dddelete three lines
Simple replace text
r{text}Replace the character under the cursor with {text}
RReplace characters instead of inserting them
Copy/Paste text
yycopy current line into storage buffer
["x]yyCopy the current lines into register x
ppaste storage buffer after current line
Ppaste storage buffer before current line
["x]ppaste from register x after current line
["x]Ppaste from register x before current line
Undo/Redo operation
uundo the last operation.
Ctrl+rredo the last undo.
Search and Replace keys
/search_textsearch document for search_text going forward
?search_textsearch document for search_text going backward
nmove to the next instance of the result from the search
Nmove to the previous instance of the result
:%s/original/replacementSearch for the first occurrence of the string “original” and replace it with “replacement”
:%s/original/replacement/gSearch and replace all occurrences of the string “original” with “replacement”
:%s/original/replacement/gcSearch for all occurrences of the string “original” but ask for confirmation before replacing them with “replacement”
Bookmarks
m {a-z A-Z}Set bookmark {a-z A-Z} at the current cursor position
:marksList all bookmarks
`{a-z A-Z}Jumps to the bookmark {a-z A-Z}
Select text
vEnter visual mode per character
VEnter visual mode per line
EscExit visual mode
Modify selected text
~Switch case
ddelete a word.
cchange
yyank
>shift right
<shift left
!filter through an external command
Save and quit
:qQuits Vim but fails when file has been changed
:wSave the file
:w new_nameSave the file with the new_name filename
:wqSave the file and quit Vim.
:q!Quit Vim without saving the changes to the file.
ZZWrite file, if modified, and quit Vim
ZQSame as :q! Quits Vim without writing changes

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.