Vim:Shortcut
lastmod 2018-08-17created 2015-02-157 edits
VIM command shortcuts VIM movement shortcuts
Notes on VIM shortcuts.
Basic movement
-
h, j, k, l: Move the cursor left, down, up, right
Switching to INSERT mode
-
i: Insert at the current cursor position -
I: Insert at the very start of the current line -
a: Insert at the position after the current cursor -
A: Insert at the very end of the current line -
o: Insert on the line above -
O: Insert on the line below
Movement
-
w: Move to the first character of a word -
W: Move to the next character, by whitespace-delimited units -
b: Move backward to the first character of a word -
B: Move backward to the next character, by whitespace-delimited units -
e: Move to the last character of a word -
ge: Move backward to the last character of a word -
gg: Move to the very start of the document -
G: Move to the very end of the document -
^: Move to the very start of the sentence -
0: Move to the very start of the line -
$: Move to the very end of the sentence -
f문자: Move to the position of the character; press;to keep moving -
F문자: Move backward to the position of the character -
t문자: Move to the position just before the character -
T문자: Move backward to the position just before the character -
zz: Brings the cursor position to the center of the screen.
Search
-
/단어: Find a word in the document; find next/previous withnorN -
*: Search forward for the current word -
#: Search backward for the current word
Screen movement
-
Ctrl + f: Move to the next page -
Ctrl + b: Move to the previous page -
Ctrl + u: Move forward by half a page -
Ctrl + d: Move back by half a page -
H: Move to the top line of the current screen -
M: Move to the middle line of the current screen -
L: Move to the last line of the current screen
Brace movement
-
]]: Move forward to an opening curly brace ({) -
[[: Move backward to an opening curly brace ({) -
][: Move forward to a closing curly brace ({) -
[]: Move backward to a closing curly brace ({) -
%: Within{}or(), move to the matching bracket of the current one
Editing
-
dd: Cut the current line -
dw: Cut a word -
yy: Copy the current line -
p: Paste -
r: Replace the current character -
u: Undo -
Ctrl + R: Redo -
x: Delete the current character -
X: Delete the preceding character -
>: Indent -
<: Outdent -
.: Repeat the previous command -
=: Apply auto-indent (use after selecting in Visual Mode)
VISUAL MODE
-
v: Visual mode -
y: Copy -
c: Cut -
cw: Cut a word -
J: Join the next line to the end of the current line -
~: Toggle the case of the selected characters -
Ctrl + A: Increment a number -
Ctrl + X: Decrement a number
Saving
-
:w: Save the document -
:q: Close the current document -
:q!: Close without saving -
:wq: Save and close -
:숫자: Move to the specified line number
TAB & WINDOW
-
:new: Open a horizontally split window -
:vs: Open a vertically split window -
Ctrl + w: Move between split windows -
:tabnew: Open a new tab -
:gt: Move to the next tab -
:gT: Move to the previous tab -
:e ./: Browse for a file to open in the current tab (./starts browsing from the current location)
FOLDING
-
zc: Fold code -
zo: Unfold folded code -
zd: Delete a fold -
zR: Unfold all folded code -
zM: Fold all code -
zD: Delete all folds
BUFFER
-
:buffers: When multiple files are open in Vim, show the list in the buffer -
:buffer 숫자: Enter a number from the buffer list to open that file (:balso works instead of:buffer) -
:bnext: Move to the next file in the buffer (:bnalso works) -
:bprevious: Move to the previous file in the buffer (:bpalso works) -
:ball: Open the files in the buffer list in horizontally split windows
TIP
-
:map: Prints the bound keymaps.