Skip to content

VIM

Basics

Vim has a few modes you need to know how to use. Command (default), extended command, edit, and visual mode. For basic usage of Vim you need to know the following: - Press I to start typing - Make sure you exit edit or visual mode before typing a command - Type :wq to save and quit, :q! to quit without saving (force quit)

Quick tips

  • hjkl can be used as arrow keys
  • u is undo
  • x will delete a single character
  • a appends to the end of a line

Modes

Switching modes

You will start in command mode. In order to type, you need to switch to edit mode by pressing I. To get back, you can press ESC.

Command mode

While in command mode, here are some commands you can use: - y & p, yank and put (copy and paste) - delete will store things to be put - a append to end of line - d delete (Selectors) - (count)dd will delete a count of lines - u undo - U undo everything on a line - ctrl+r to redo - r replace - replaces the current character with the next character typed - c change - deletes up to a certain selector and puts the terminal in insert mode - cc to change the whole line - g - Ctrl+G display current line and file info -

Selectors

  • w - until the start of the next word, EXCLUDING its first character.
  • e - to the end of the current word, INCLUDING the last character.
  • $ - to the end of the line, INCLUDING the last character. These can also be used to move the cursor as specified. 0 will move to the end of the line, and any other number can be used to multiply any motion.

Visual mode

  • Character mode : *v*
  • Line mode : *Shift*+v****
  • Block mode : *Ctrl*+v****