Skip to content

Instantly share code, notes, and snippets.

@de1o
Last active December 14, 2015 17:48
Show Gist options
  • Save de1o/5124320 to your computer and use it in GitHub Desktop.
Save de1o/5124320 to your computer and use it in GitHub Desktop.
vi's skills in kindgarden level. Add these to your repertoire ASAP.
  • ctrl v(linux)/ctrl q(windows): enable visual block mode(column edit)

navigation

  • Enter/+: move to the first non-blank char of next line.
  • H: move to the first line of current screen.
  • L: move to the last line of current screen.
  • -: move to the first non-blank char of previous line.
  • ^: move to the first non-blank char of current line.
  • 0: move to the first char(blank char included) of current line.
  • w: move to the head of next word.
  • b: move to the head of previous word.
  • e: move to the tail of current word.
  • E: move to the tail of current word, punctuation will be treated as part of the word.
  • (: move to the head of current sentence. (sentence is identified by punctuations like .!? and a blank space after it.
  • ): move to the head of next sentence. (Note: not the tail of current sentence but...)
  • {}: paragraph version of ()(Note: paragraph is identified by blank line)
  • [[, ]]: section version of ()(TODO: so what's the identifier of section)
  • fx: search x after cursor in current line, then move cursor to this char(if existed).
  • Fx: reverse version of fx.
  • t/T: same as the f/F commands, except for moving cursor to the char before x.
  • ;: redo previous inline search command in the same direction.
  • ,: reverse version of ; command.

delete and replace

  • rc: replace char under cursor with c.
  • nx: delete n chars since cursor.
  • dw: delete word since cursor.
  • db: delete word before cursor.
  • ndd: delete n lines since cursor.

copy and paste

when contents been deleted from text, they actually been copied in a buffer.

  • p: paste contents in the buffer after the cursor.
  • P: paste contents in the buffer before the cursor.
  • yy: copy current line to buffer.
  • nyy: copy next n lines to buffer since cursor.
  • (Note: when copying and pasting lines, new lines will be paste before/after the current line instead of cutting current line.)

insert mode

  • o: add a new line after current line and enter insert mode.
  • O: kind of like o. u know the diffence.
  • ns: delete next n chars since cursor and enter insert mode.
  • cw: hello next word since cursor and enter insert mode.(change word?)
  • cb: (change back?)
  • c$: u know
  • c0: u know

Edited by GVIM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment