rtorr/vim-cheat-sheet

Add some new commands

mu2so4 opened this issue · 0 comments

There are some useful commands:

  1. :ba[ll] - edit all buffers as horizontal windows;
  2. <% - de-indent a block with () or {} (cursor on brace);
  3. :mak[e] - execute external command makeprg and parse error messages. It's like exiting Vim, executing make in terminal, and reopening the file(s), but with error logs in the quickfix window;
  4. g? - Rot13 encode up to motion. I'm not sure this command is useful.

There are other flags for the :s[ubstitude] command:

  1. :%s[ubstitute]/old/new - replace all "old" first occurrences within lines with "new" throughout file
  2. :%s[ubstitute]/old/new/i - replace all "old" first occurrences within lines with "new" throughout file (ignore case)

Also one can use different ranges, not only "%" which means the entire buffer:

  1. :12,26s/old/new/g - replace all "old" with "new" from 12th to 26th lines inclusively;
  2. :31s/old/new/g - replace all "old" with "new" in the 31st line;
  3. :s/old/new/g - replace all "old" with "new" in the line under the cursor.

These ranges may be used for other commands (e. g. :d, :>, etc.).