Vim

How-To

Run a command based on selected text

By selecting text in visual mode, you can run a terminal command on that selection as input, with the output being put back into the current buffer.

Reference

Keybindings

Basic Movement

Key Action
H Move cursor left
J Move cursor down
K Move cursor up
L Move cursor right
G+J Move cursor down (multi-line text)
G+K Move cursor up (multi-line text)

Screen Navigation

Key Action
Shift+H Move to top of screen
Shift+M Move to middle of screen
Shift+L Move to bottom of screen
Z+Z Center cursor on screen
Z+T Position cursor on top of the screen
Z+B Position cursor on bottom of the screen

Word Movement

Key Action
W Jump forwards to the start of a word
Shift+W Jump forwards to the start of a word (words can contain punctuation)
E Jump forwards to the end of a word
Shift+E Jump forwards to the end of a word (words can contain punctuation)
B Jump backwards to the start of a word
Shift+B Jump backwards to the start of a word (words can contain punctuation)
G+E Jump backwards to the end of a word
G+Shift+E Jump backwards to the end of a word (words can contain punctuation)

Line Navigation

Key Action
0 Jump to the start of the line
_ Jump to the first non-blank character of the line
++dollar++ Jump to the end of the line
G+_ Jump to the last non-blank character of the line

Document Navigation

Key Action
G+G Go to the first line of the document
Shift+G Go to the last line of the document
5+G+G or 5+Shift+G Go to line 5
G+D Move to local declaration
G+Shift+D Move to global declaration
Key Action
F+X Jump to next occurrence of character x
T+X Jump to before next occurrence of character x
Shift+F+X Jump to the previous occurrence of character x
Shift+T+X Jump to after previous occurrence of character x
; Repeat previous f, t, F or T movement
, Repeat previous f, t, F or T movement, backwards

Block/Paragraph Navigation

Key Action
++right-brace++ Jump to next paragraph (or function/block, when editing code)
++left-brace++ Jump to previous paragraph (or function/block, when editing code)
++percent++ Move cursor to matching character (default supported pairs: (), {}, [] - use :h matchpairs in Vim for more info)

Screen Scrolling

Key Action
Ctrl+E Move screen down one line (without moving cursor)
Ctrl+Y Move screen up one line (without moving cursor)
Ctrl+B Move screen up one page (cursor to last line)
Ctrl+F Move screen down one page (cursor to first line)
Ctrl+U Move cursor and screen up 1/2 page
Ctrl+D Move cursor and screen down 1/2 page

Run a command in the shell from vim

:! command argument