INNER PEACE

Learn Some Vim and Save Your Time

Vim is Invincible

Some Vim commands I learned to use myself. Most of them can be found in the links at the end of the article.

Survive

  • vi/vim -> open the editor
  • :q -> Quit
  • :wq -> Save and Quit
  • :q! -> Quit and Not Save
  • i -> Insert mode
  • x -> Delete the char under the cursor
  • dd -> Delete the current line
  • pP -> Paste to above or under the current line
  • yy -> Copy current line
  • hjkl -> Right, Down, Up, Left

Feel comfortable

  • a -> Insert after the cursor
  • oO -> Insert a new line after/before the current one
  • 0 -> Go to the first column
  • ^ -> go to the first non-blank character of the line
  • $ -> go to the end of line
  • g_ -> go to the last non-blank character of line
  • /pattern -> search for pattern
  • u -> undo
  • <C-r> -> redo
  • :e <path/to/file> -> open file
  • bn,bp -> show next/previous file (buffer)

Feel Better, Stronger, Faster

  • . -> Repeat the last command
  • N<command> -> Repeat the command N times.
  • NG -> Go to N line
  • gg -> Go to first line
  • G -> Go to last line
  • b -> Open one buffer file
  • % -> Go to the corresponding (, {, [.
  • * -> go to next/previous(#) occurrence of the word under the cursor

Vim Superpowers

  • f<char>, ;, , -> Find one char on the current line, ; go to the next same char, ‘,’ go back to the last same char
  • t, -> Go to just before the character ,
  • F,T -> Like f and t but backward
  • <C-p> -> Go to the previous line
  • <C-n> -> GO to the next line
  • <C-d> -> Go down a half screen
  • <c-u> -> Go up a half screen
  • {,} -> previous/next empty line
  • v,V,<C-v> -> Visual mode
  • :split, :vsplit -> split the window
  • tabnew -> open a new tab

referrence:

Learn Vim Progressively

Learn Vimscript the Hard Way

Practical Vim: Edit Text at the Speed of Thought