Vim Cheatsheet
Johnny Miller, Sun Oct 2 13:58:53 CST 2022
Vim (/vɪm/; a contraction of Vi IMproved) is a free and open-source, screen-based text editor program. It is an improved clone of Bill Joy's vi.
📖 References
Table of Contents
[TOC]
- Operators let you operate in a range of text (defined by motion). These are performed in normal mode. See more: Motions and operators
- Text objects let you operate (with an operator) in or around text blocks (objects).
Keystroke(s) | Description | Note |
---|---|---|
h j k l |
Arrow keys (⬅️ ⬇️ ⬆️ ➡️) | |
b / w |
Previous/next word | |
ge / e |
Previous/next end of word | |
0 (zero) |
Start of line | |
^ |
Start of line (after whitespace) | |
$ |
End of line | |
gg |
First line | |
G |
Last line | |
:n |
Go to line n |
|
nG |
Go to line n |
|
zz |
Center this line in editor window | |
zt |
Top this line in editor window | |
zb |
Bottom this line | |
H |
Move to top of screen | |
M |
Move to middle of screen | |
L |
Move to bottom of screen | |
/pattern |
Search for pattern | |
?pattern |
Search backward for pattern | |
n |
Next matching search pattern | |
N |
Previous match | |
gd |
Go to definition | JetBrains |
{ / } |
Jump to previous/next paragraph | Visual mode |
Keystroke(s) | Description | Note |
---|---|---|
a |
Append | |
A |
Append from end of line | |
i |
Insert | |
o / O |
Next line Add blank line below/above current line | |
J |
Join next line of text with current line | JetBrains plugin: ideajoin |
s |
Delete char and insert | |
S |
Delete line and insert | |
C |
Delete until end of line and insert | |
cc |
Delete whole line and insert | |
dd |
Delete line (Cut) | The deleted texts will be copied in Vim’s clipboard |
2dd |
Delete 2 lines (Cut) | |
dw |
Delete to next word | |
db |
Delete to beginning of word | |
ciw |
Change (replace) entire word. (Delete current word that pointed by cursor) | |
cw / ce |
Change (replace) to the end of the word. | |
u |
Undo changes | |
<C-R> |
Redo changes | <C-R> = ctrl + r |
Esc / <C-[> |
Exit insert mode | <C-[> = ctrl + [ |
<C-C> |
Exit insert mode (corrupt), and abort current command | <C-C> = ctrl + c |
< / > |
Indent right/left | Visual mode. Operators |
= |
Autoindent |
Keystroke(s) | Description | Note |
---|---|---|
x |
Delete character (Cut) | The deleted character will be copied in Vim’s clipboard |
dd |
Delete line (Cut) | Copy in Vim’s clipboard |
yy |
Yank line (Copy) | Copy in Vim’s clipboard |
p |
Paste from Vim’s clipboard | |
P |
Paste before from Vim’s clipboard | |
"*p / "+p |
Paste from system clipboard | |
"*y / "+y |
Paste to system clipboard |
Keystroke(s) | Description | Note |
---|---|---|
v |
Enter visual mode | |
V |
Enter visual line mode | |
<C-V> |
Enter visual block mode | |
a |
Enter insert node and append text after where cursor is | |
i |
Enter insert node and insert text before where cursor is | |
Esc / <C-[> |
Exit insert mode | <C-[> = ctrl + [ |
Text objects let you operate (with an operator) in or around text blocks (objects).
v |
i |
p |
---|---|---|
Operator | [i]nside or [a]round | Text object |
Keystroke(s) | Description | Note |
---|---|---|
vip |
Select paragraph | |
yip |
Yank inner paragraph | |
ciw |
Change (replace) entire word | |
ggvG |
Select all text. (Go to top, visual mode, go to bottom) |
Keystroke(s) | Description | Note |
---|---|---|
m{a-z} |
Set mark {a-z} at cursor position | |
m{A-Z} |
A capital mark {A-Z} sets a global mark and will work between files | |
``{a-zA-Z}` | Move cursor to the position where the mark was set | |
'{a-zA-Z} |
Move cursor to the start of the line where the mark was set | |
'' |
Go back to the previous jump location | |
:marks |
List marks | |
:delmarks {a-zA-Z} |
Delete specific marks | |
:delm abc |
Delete marks a, b and c | |
:delm! |
Delete all marks but not marks A-Z |
Vimium Cheatsheet
Vimium is a browser extension that provides keyboard-based navigation and control of the web in the spirit of the Vim editor.
📖 References
Keystroke(s) | Description | Note |
---|---|---|
? |
Show the help dialog for a list of all available keys | |
h j k l |
Arrow keys (⬅️ ⬇️ ⬆️ ➡️) | |
gg |
Scroll to top of the page | |
G |
Scroll to bottom of the page | |
d |
Scroll down half a page | |
u |
Scroll up half a page | |
f |
Open a link in the current tab | |
F |
Open a link in a new tab | |
r |
Reload page | |
gs |
View source | |
i |
Enter insert mode -- all commands will be ignored until you hit Esc to exit | |
yy |
Copy the current url to the clipboard | |
yf |
Copy a link url to the clipboard | |
o |
Open URL, bookmark, or history entry | |
O |
Open URL, bookmark, history entry in a new tab | |
b |
Open bookmark | |
B |
Open bookmark in a new tab | |
/ |
Enter find mode -- type your search query and hit enter to search, or Esc to cancel | |
n / N |
Next/previous matching search pattern | |
H |
Go back in history | |
L |
Go forward in history | |
J |
Go one tab left | |
K |
Go one tab right | |
^ |
Visit the previously-visited tab | |
t |
Create new tab | |
yt |
Yank (duplicate) current tab | |
x |
Close current tab | |
X |
Restore closed tab (i.e. unwind the 'x' command) | |
T |
Search through your open tabs | |
W |
Move current tab to new window | |
<a-p> |
Pin/unpin current tab | |
ge |
Edit the current URL | |
gE |
Edit the current URL and open in a new tab |
To activate search completion, type o
to activate vomnibar and then type the search completion keyword as defined in settings (such as 'g') and press space.
Keystroke(s) | Description | Note |
---|---|---|
w |
https://www.wikipedia.org/w/index.php?title=Special:Search&search=%s | Wikipedia |
g |
https://www.google.com/search?q=%s | |
l |
https://www.google.com/search?q=%s&btnI | I'm feeling lucky... |
yt |
https://www.youtube.com/results?search_query=%s | YouTube |
gm |
https://www.google.com/maps?q=%s | Google Maps |
b |
https://www.bing.com/search?q=%s | Bing |
yd |
https://yandex.com/search/?text=%s | Yandex |
d |
https://duckduckgo.com/?q=%s | DuckDuckGo |
az |
https://www.amazon.com/s/?field-keywords=%s | Amazon |
gh |
https://github.com/search?q=%s | GitHub |
These are to resolve shortcuts like
ctrl + d
, which causes conflict on the Windows platform, not on macOS.