Vim
The best $EDITOR.
Learn
- Touch typing
vimtutor:help user-manual- YT: Mastering the Vim Language
- #todo Practical Vim by Drew Neil

💡 Hint
MapCaps LocktoESCfor easier switching to Normal mode.
Language
Modes:
- Normal: default (enter with
Esc) - Insert: edit text (enter with
i,a, etc.) - Visual: select characters (enter with
v) - Visual (lines): select lines (enter with
V) - Visual (block): select blocks (enter with
Ctrl+v) - Command: run builtin/external commands (enter with
:)
Editing:
- A motion moves the cursor (e.g.
wmoves to the next word). - An operator changes the text (e.g.
ddeletes the text). - Motions and operators combined together operate on the text that was moved over (e.g.
dwdeletes to the next word). - A number before a motion/operator repeats it that many times (e.g.
3dwdeletes the next 3 words). - An operator repeated twice operates on the current line (e.g.
dddeletes the current line). - An uppercase operator operates on the rest of the current line (e.g.
Ddeletes the rest of the line). - An uppercase motion includes non-alphanumeric characters such as punctuation and brackets.
- Some operators operate immediately (e.g.
x), others require a motion (e.g.d). - A text object represents a text token (e.g. word, sentence, paragraph).
- An operator can operate (i)nside or (a)round a text object (e.g.
diwdeletes only the current word,dawdeletes also the surrounding whitespace). - A buffer is some text in memory. A window is a viewport on a buffer. A tab is a set of windows.
Motions:
hjkl: left/down/up/rightw: to the start of the next worde: to the end of the next wordb: to the start of the previous wordge: to the end of the previous wordf<c>: to the nextccharactert<c>: to the character before the nextccharacter;/,: repeat the previousf/tjump forward/backward0: to the start of the line$: to the end of the line^/_: to the first non-blank character of the line%: to the matching bracketgg: to the first lineG: to the last line<n>gg: to the nth line(/): to the previous/next sentence{/}: to the previous/next paragraphCtrl+o/i: to the previous/next positionCtrl+b/f: page up/downCtrl+u/d: half page up/down- (Visual)
o: to the other end of the selection
Operators:
i: insert before the cursora: insert after the cursorI: insert at the start of the lineA: insert at the end of the lineo/O: insert below/above the liney: yank the textc: change the textd: delete the textp: put the previously yanked/changed/deleted textx: delete the characters: delete the character and insertr<c>: replace the character withcJ: join two lines~: switch case of the characterg~: switch casegu/gU: to lower/upper casegv: repeat the last selection>/</=: indent/unindent/autoindentu: undo the last changeCtrl+r: redo the last change.: repeat the last change
Text objects:
w: words: sentencep: paragrapht: tagb: synonym for(/)B: synonym for{/}- any bracket
- any quote
Tricks:
ea: append to the wordxp: swap two charactersddp: swap two linesgg=G: autoindent the whole buffer
Search:
//?: search forward/backward*/#: search the current word forward/backwardn/N: to the next/previous result
Replace:
:s/old/new: replace in the current line:%s/old/new: replace in the whole buffer:'<,'>s/old/new: replace in the selection- Modifiers:
g(all),c(confirm)
Commands:
:q[uit]: quit Vim:w[rite]: write changes:e[dit]!: discard changes:e[dit] <file>: edit file:!<cmd>: run an external commandCtrl+z: suspend Vim (resume withfg)
Registers:
": unnamed register (default)<a-z>: named registers<A-Z>: named registers (append)<1-9>: delete queue0: the last yank/: the last search:: the last command+: system clipboard_: black hole register
Macros:
q<a-z>: record a macro (qto stop recording)@<a-z>: play a recorded macro@@: replay the last macro
Neovim
A community-driven fork of Vim.
Features:
- Configurable with Lua
- Builtin support for LSP and Treesitter
Setup: