Skip to content

Instantly share code, notes, and snippets.

@dlanileonardo
Last active September 3, 2015 23:17
Show Gist options
  • Save dlanileonardo/8d98b0cd12a8431db060 to your computer and use it in GitHub Desktop.
Save dlanileonardo/8d98b0cd12a8431db060 to your computer and use it in GitHub Desktop.
Vim Tips, Shortcuts and Plugins

Based in my .vimrc

Basic movements:

  • h Move left
  • j Move down
  • k Move up
  • l Move right
  • $ Move to end of line
  • 0 Move to beginning of line (including whitespace)
  • ^ Move to first character on lineg
  • gg Move to first line of file
  • G Move to last line of file

Smart movements:

  • w Move forward to next word, with cursor on first character (use W to jump by whitespace only)
  • b Move backward to next word, with cursor on first character (use B to jump by whitespace only)
  • e Move forward to next word, with cursor on last character (use E to jump by whitespace only)
  • ge Move backwards to next word, with cursor on last character (use gE to jump by whitespace only)
  • ( Move to beginning of previous sentence. Use ) to go to next sentence
  • { Move to beginning of previous paragraph. Use } to go to next paragraph
  • + Move forward to the first character on the next line
  • - Move backwards to the first character on the previous line
  • * and # search for the word under the cursor forward/backward.
  • % jump to the matching { .. } or ( .. ), etc..
  • '. jump back to last edited line.
  • g; jump back to last edited position.

Quick editing commands:

  • I insert at the begin.
  • A append to end.
  • o / O open a new line after/before the current.
  • v / V / Ctrl+V visual mode (to select text!)
  • Shift+R replace text
  • C change remaining part of line.

Delete:

  • dm Delete in direction of movement m. For m, you can also use w, b, or any other variation
  • dd Delete entire current line
  • D Delete until end of line

Delete a Word:

  • daw delete the around the word
  • diw delete the in word
  • caw delete the around the word and put you in insert mode

Select a Text:

  • v% if the cursor is on the starting/ending parenthesis
  • vib if the cursor is inside the parenthesis block
  • vi" for double quotes
  • vi' for single quotes
  • viB select a Block
  • vi{ selecte inner {
  • ggVG Ctrl+A

Copy and Paste & Yank:

  • d Cut
  • dd Cut Line
  • y Yank (copy) highlighted text
  • yy Yank current line
  • p Put (paste) yanked text below current line
  • P Put yanked text above current line
  • J Join current line with the next line. Use gJ to exclude join-position space

Miscellaneous:

  • u Undo
  • U Undo all changes on current line
  • <Ctrl>+r Redo
  • <F3> Clear All Search Highlights
  • <F4> Toggle Line Numbers
  • \r Refresh File Contents
  • <F10> Smart Save
  • \rs Remove spaces

Motion

  • "dl" delete character (alias: "x") |dl|
  • "diw" delete inner word diw
  • "daw" delete a word daw
  • "diW" delete inner WORD (see |WORD|) diW
  • "daW" delete a WORD (see |WORD|) daW
  • "dd" delete one line |dd|
  • "dis" delete inner sentence dis
  • "das" delete a sentence das
  • "dib" delete inner '(' ')' block dib
  • "dab" delete a '(' ')' block dab
  • "dip" delete inner paragraph dip
  • "dap" delete a paragraph dap
  • "diB" delete inner '{' '}' block diB
  • "daB" delete a '{' '}' block daB

Plugins Tips:

File Navigation/Search

  • <Ctrl>-p Instant File Search per name
  • <space>f File Search per content
  • <space>y Yank Search
  • <space>s Buffer Search
  • \sh Open a Shell
  • <F7> Open VimFiler
  • <F6> Open the Bufexplorer
  • <F8> Open TagBar
  • <C-E>, Trigger Emmet Snippet

Utils

  • <Ctrl>-c Toggle comment line
  • <Ctrl>-y, Trigger to snippet
  • \s(key search)(key target) Findo character
  • <Ctrl>-n Select next Ocurrence
  • <Ctrl>-p Clear current virual cursor and go back to the previous
  • <Ctrl>-x Skip next Ocurrence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment