Vim Advanced - Day 3

Vim Advanced - Day 3

  • 2020-2-29
  1. g+a Show ASCII value of character under cursor
  2. <+< Shift lines to left
  3. >+> Shift lines to right
  4. C-a Increase number under cursor
  5. y+s+text-object+surrondings Enclose the text object with surroundings
  6. c+s+text-object+old-surrondings+new-surrondings Change the surrondings of the text object
  7. d+s+text-object+surrondings ReMove the surroundings of the text object
  8. V enter visual line mode first; S+surrondings add surrondings linewise. (for instance, V C <p class='important'>)
  9. Nouns: w: word; s: sentence; p: paragraph; t tag;
  10. D Remove the text after the cursor of the current line, which is similar to C (C will also enter into insert mode)
  11. * Search for other instances of the word under your cursor
  12. ^ Move to the first non-blank character in the line, which is a little different from 0 (Move to the beginning of the line)
  13. $ Move to the end of the line
  14. Move by word: w/W: Move forward one word; b/B Move back one word; e/E Move to the end of the word;
  15. Move by sentence: ( Move back one sentence; ) Move forward one sentence
  16. Move by paragraph: { Move back one paragraph; } Move forward one paragraph
  17. Move by screen: H Move to the top of the screen; M Move to the middle of the scrren; L Move to the bottom of the screen; C-u Move up half a screen; C-d Move down half a screen
  18. Move by file: gg Move to the beginning of the file; G Move to the end of the file
  19. C-i Jump forward the cursor's location; C-o Jump backward the cursor's location (I guess Vim maintains a cursor location stack to achieve it)
  20. s delete the character under cursor and enter into insert mode (think about x)
  21. S dlete the current line and enter into insert mode, which equals to c+c
  22. Substitution: :%s/foo/bar/gc Replace "foo" to "bar" on every line with confirm (! Note that :%s/foo/bar/cg is not working, the sequence of c and g is sensitive); :s/foo/bar/gc Replace "foo" to "bar" on current line
  23. / Search forward; ? Search backward

Ref: Learn Vim For the Last Tiem: A Tutorial and Primer