Vim
Text
dawdelete word under cursord/cib- delete a block surrounded by (d/ciB- delete a block surrounded by {d/cas- delete a sentenced/cap- delete a paragraph- Visual select the text, then
Ufor uppercase orufor lowercase. To swap all casing in a visual selection, press~(tilde).
Windows
CTRL-W= equal size
CTRL-W- decreases the current window
:vsp vertically split windows
:e edit new file in current buffer
<C-^> quickly switch buffer (this and before, only 2 buffers will be loaded)
Dot .
Can be used only after text is changed
Macros
Macros | Vim Tips Wiki | Fandom
q<letter><commands>q where letter is a-z
<number>@<letter> to use
Movements
JK move 5 lines
R replace more char
HL move to beginning or end, equivalent to ^$
Indent
<G / >G to indent (. to repeat)
Tricks
-
Write as sudo
:w !sudo tee%
-
Set
-as a wordset iskeyword+=-
Vim Surround
| Surround Command | Description |
|---|---|
y s <motion> <desired> | Add desired surround around text defined by <motion> |
d s <existing> | Delete existing surround |
c s <existing> <desired> | Change existing surround to desired |
S <desired> | Surround when in visual modes (surrounds full selection) |
Some examples:
"test"with cursor inside quotes typecs"'to end up with'test'"test"with cursor inside quotes typeds"to end up withtest"test"with cursor inside quotes typecs"tand enter123>to end up with<123>test</123>