Skip to content

Instantly share code, notes, and snippets.

@steveclarke
Created April 10, 2012 13:53
Show Gist options
  • Save steveclarke/2351533 to your computer and use it in GitHub Desktop.
Save steveclarke/2351533 to your computer and use it in GitHub Desktop.
Vim Reference

Movement

Move in screen: L low, M middle, H high

{ and } jump by paragraph

t<char> — Move forward until the next occurrence of the character.

f<char> — Move forward over the next occurrence of the character.

T<char> — Move backward until the previous occurrence of the character.

F<char> — Move backward over the previous occurrence of the character.

Selection

ctrl-v - visual block mode

Misc

xp to change the order of two characters.

ddp to change the order of two lines. (mnemonic Diddy-P LOL)

* - search for the word under cursor, then n/p to jump to next/previous.

:bd - buffer delete; close file without closing Vim window

Ctrl-A / Ctrl-X - increment/decrement number under cursor. Use with # to add

Map a key command to save and run a file:

:map ,r :w\|:!ruby foo.rb<cr>

Convert spaces to tabs:

:set expandtab
:retab

Case

~ - toggle case

:tildeop will make ~ act as an operator such as d or c, so that you can type ~4w to invert the case of the next 4 words.

gu + motion – Change text to lower case

gU + motion – Change text to upper case

Change

ciw ("change inner word") change word under cursor

ci" change double-quoted string (but keep the quotes)

ci( change text between matching parentheses, also works with brackets

cc change whole line

ct_ - change to underscore, etc.

Named Buffers

"ayy - yank to named buffer a

"ap - paste buffer a

Marking

ma - mark position a

'a - move cursor to line containing a

```a`` - move cursor to the character marked by a

Todo

Study up on `y' commands: good article

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment