Vim

Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient.

Configure

A full list of configuration options and their current settings can be found by running :options.

Modes

Vim is a modal text editor. This means that, unlike basic editors, Vim operates in one of multiple states optimized for specific types of interaction. There are seven "basic" modes (plus seven "additional" modes).

  • Normal
  • Visual
  • Select
  • Insert
  • Command-line
  • Ex
  • Terminal-job

View the modes introduction by running :h vim-modes-intro

Operators

  • c - change
  • d - delete
  • y - yank into register
  • gU - make uppercase
  • gu - make lowercase
  • > - shift right
  • < - shift left

View the complete list by running :h operator

Motions

Word motions

  • w [count] words forward - Delimitated by non-keyword characters
  • W [count] WORDS forward - Delimitated by whitespace
  • e forward to end of word [count]
  • E forward to end of WORD [count]
  • b - [count] words backward
  • B - [count] WORDS backward

View the complete list by running :h word-motions

Text object motions

View the complete list by running :h object-motions

Selections

  • ap - A paragraph
  • ip - Inner paragraph

Completion

  • <C-x><C-f> - File completion

Typed commands

  • :buffer :b - Edit buffer from the buffer list
  • :find - Find {file} in path and :edit it
  • :sort - Sort lines in [range]. When no range is given all lines are sorted

Key commands

Change

  • c{motion} - "Change" - Delete {motion} text [into register x] and start insert
  • cc - Delete [count] lines [into register x] and start insert
  • C - Delete from cursor to end of the line [into register x] and start insert

Delete

  • d{motion} - Delete text that {motion} moves over [into register x]
  • dd - Delete [count] lines [into register x] linewise
  • D - Delete the characters under the cursor until the and of the line

Upper/lower case

  • gU{motion} - Make motion text uppercase
  • gu{motion} - Make motion text lowercase
  • {visual}U - Make highlighted text uppercase
  • {visual}u - Make highlighted text lowercase

Scrolling relative to cursor

  • zt - Redraw, line [count] at top of window
  • zz - Redraw, line [count] at center of window
  • zt - Redraw, line [count] at bottom of window

Editing text

  • a - Append text after the cursor
  • A - Append text at the end of the line

Resources