vim commands for the Windows user

This is a cheat sheet for Windows keyboard junkies who feel as out of place in vi as I do. I got most of the vim commands from the rather useful IBM vi tutorial. dd was the only one I ever learnt (and I didn’t know that I could paste after deleting it). There’s loads more vim commands, I’ve just listed the ones that are most similar to Windows ones.

Alot of the vim commands are two letters together e.g. dd. To do these just tap the two letters quickly. N.B. capitalisation matters. So moving to line 100 in vi is type 100 then hit Shift+G quickly. But capital G, V & P are the only three capitals we use.

Update: I’ve just come across this excellent article on learning to speak vim, to get a more in depth understanding.

Quick start

Ctrl+Home = gg
Ctrl+End  = G
Ctrl+x    = dw / dd / dG
Ctrl+c    = yw / yy / yG
Ctrl+v    = p

Moving around

Command Windows (Notepad) Vi (command mode) Notes
First line Ctrl+Home gg
Last line Ctrl+End G
Line N Ctrl+g, N, Enter Ngg e.g. 100, g, g quickly
End of the line End $ or End
Start of the line Home 0 or Home
Next word Ctrl+Right w
Previous word Ctrl+Left b
Page up Pg Up Ctrl+u or Pg Up Ctrl+u acts more similarly to Pg Up in Windows as Pg Up won’t take the cursor all the way to the top in vi.
Page down Pg Dn Ctrl+d or Pg Dn
Find text Ctrl+f, [text], Enter (forward) /[regex] (forward) regex (regular expression): so you need to escape dots and backslashes e.g. \. \/
Replace text Ctrl+h, [search], [replace], Enter (forward)
  • :s/[search]/[replace]/, Enter (line)
  • :%s/[search]/[replace]/, Enter (replace all)
The vi search and replace are regex

Cut, Copy, Paste

Command Windows (Notepad) Vi (command mode) Notes
Delete Delete x or Delete x does a cut too
Select Word
  • Double-click word
  • Ctrl+Left, Ctrl+Shift+Right (or vice-versa)
vw
Select Line
  • Left-click in margin
  • Home, Shift+End
  • Home, Shift+Down
V
Select All
  • Ctrl+a
  • Ctrl+Home, Ctrl+Shift+End
gg, VG
Delete Word Select Word, Delete dw
Delete Line Select Line, Delete dd
Delete rest of line Shift+End, Delete d$
Delete New line
  • End, Delete (next)
  • Home, Backspace (prev)
J (next)
Delete All Select All, Delete gg, dG
Copy Word Select Word, Ctrl+c yw Select Word, right-click,
yw, p/P
Copy Line Select Line, Ctrl+c yy y aka ‘Yank’
Copy All Select All, Ctrl+c gg, yG
Cut Word Select Word, Ctrl+x Delete Word
Cut Line Select Line, Ctrl+x Delete Line
Cut All Select All, Ctrl+x Delete All
Paste Ctrl+v
  • p (after cursor)
  • P (before cursor)

Undo, Redo

Command Windows (Notepad) Vi (command mode) Notes
Undo Ctrl+z u
Redo Ctrl+y Ctrl+r

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.