Skip to content

Vim - Getting Comfortableλ︎

Getting comfortable with the Vim approach to text manipulation can take a little while. The quickest approach is to force yourself to use Vim and stick at it until you finally go faster than you were before you started. This can take a few days of slowness, but it is worth it, so find a few days when you are not as busy and have time to practice.

Start with the built in Emacs EVil Tutor - SPC h T

Helpful websites for Vim commands and keybindingsλ︎

Basic Movementλ︎

Keys in Evil Normal mode for moving the cursor around the buffer.

Keybinding Action
w move to start of next word
b move to start of previous word
e move to end of current word
j move one line down
k move one line up
l move one character right
h move one character left
gg jump to top of buffer
G jump to bottom of buffer
$ jump to end of line
^ or 0 jump to start of line
C-v page down buffer (visual block selection in Spacemacs)
C-u page up buffer
f jump to next instance of

Hint::λ︎

  • Use avy for jumping anywhere in your buffers Avy commands are in the jump/join/split menu - SPC j

Spacemacs menu - jump

Hint::λ︎

$ and ^ for jumping to end and beginning of line is the same syntax as regex

Insertλ︎

Return to Normal mode using ESC or fd pressed in rapid succession

Keybinding Action
i Enter insert mode
o Move to line below > Insert mode
O Move to line above > Insert mode

Delete textλ︎

Keybindings Actions
x Cut current character
dw delete current word
dd delete current line
d$ or dD delete from current position to end of line
di" delete inside ""
diw delete inside current word
dt" delete to next " (can delete to any character)
dT" delete to previous " (can delete to any character)
dit [html-mode] delete contents of an html tag

Manipulate textλ︎

Keybinding Action
C-j Split line at cursor
S-j Join next line to end of current line
dd or C-k Delete current line
M-; Insert comment characters (based on buffer mode)

Visual Mode - selecting textλ︎

Enter visual mode using v or C-SPC

S-v - visual mode line by line C-v - visual mode in region

Keybinding Action
y copy (yank) on to kill ring

edit-multiple-lines (visual mode)λ︎

TODO: refactor

v
shift-i
type your comment
Enter (puts the comment at the start of the line)

multi-highlight (visual mode)
v
/
name of text you want to highlight
Enter
n

Replaceλ︎

The following allow you to replace text

Keybinding Action
r replace character
~ Uppercase current character
cw change current word
cc change line

C-a i/d - increasing/decreasing a number

Vim commandsλ︎

:explore :registers - shows the recent actions that you have done