Skip to content

Instantly share code, notes, and snippets.

@t18n
Last active September 15, 2020 13:19
Show Gist options
  • Save t18n/59832f706271ce4f47937baa515fecb7 to your computer and use it in GitHub Desktop.
Save t18n/59832f706271ce4f47937baa515fecb7 to your computer and use it in GitHub Desktop.
[VIM] Vim cheatsheet #vim #ide #editor #programming-tool

VIM cheetsheets

General

  • .: Repeat last command

Moving Cursor with Word

  • e: Move to end of word
  • w: Move to beginning of word (prepend number to specify how many word)
  • W: Move forward a WORD, any non-whitespace characters (prepend number to specify how many word)
  • b: Move backward to the beginning of a word. (prepend number to specify how many word)

Moving Cursor with Lines

  • $: Move end of line
  • 0: Move beginning of line
  • k or Up: Move up 1 line (prepend number to specify how many lines)
  • j or Down or Enter: Move down 1 line (prepend number to specify how many lines)
  • : 10 Enter: Jump to line 10

Moving Cursor with Screen

  • H or gg: Jump to the top of the screen.
  • M: Jump to the middle of the screen.
  • L or G: Jump to the bottom of the screen.

Deleting

  • daw : Delete the word under the cursor (prepend number to specify how many words)
  • caw : Delete the word under the cursor and put you in insert mode
  • dw: Delete a word from the cursor
  • dd: Delete current line

Indentation

  • >>: Indent line by shiftwidth spaces

  • <<: De-indent line by shiftwidth spaces

  • 5>>: Indent 5 lines

  • 5==: Re-indent 5 lines

  • >% : Increase indent of a braced or bracketed block (place cursor on brace first)

  • =% : Reindent a braced or bracketed block (cursor on brace)

  • <% : Decrease indent of a braced or bracketed block (cursor on brace)

  • ]p : Paste text, aligning indentation with surroundings

  • =i{: Re-indent the 'inner block', i.e. the contents of the block

  • =a{: Re-indent 'a block', i.e. block and containing braces

  • =2a: Re-indent '2 blocks', i.e. this block and containing block

  • >i{: Increase inner block indent

  • <i{: Decrease inner block indent

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