Francisco Fuentes

Person who happens to code and also loves music and books

Vim commands

21 Sep 2020 » unix

In case we forget which commands to use.

Commands

  • i: Insert mode
  • h: moves cursor to the left
  • j: moves the cursor down
  • k: moves the cursor up
  • l: moves cursor to the left
  • v: selects a character
  • V: selects a whole line
  • d: cuts a character
  • dw: cuts a word from the cursor position
  • o: adds a line below the cursor
  • O: adds a line above the cursor
  • d0: cuts from the cursor back
  • d$: cuts from the cursor to the end
  • y: copies a character
  • yy: copies a line including breaklines
  • y$: copies a line without breakline
  • yiw: copies a word without spaces
  • yaw: copies a word with spaces
  • x: deletes a character in front of the cursor
  • X: deletes a character behind the cursor
  • p: paste
  • Ctrl+R, “: paste in insertion mode
  • gg: goes to the beginning of the file
  • GG: goes to the end of the file
  • ?: search within the text
  • r: replaces a character
  • :s/foo/bar/g: replaces in the current line
  • :%s/foo/bar/g: replaces across the file
  • :1,5s/foo/bar/g: replaces between the lines
  • :e (archivo) : opens another file to modify it
  • ~: changes letter format (mayus to minus, etc)
  • ZZ: saves and closes

Related Posts