This is an archive of the From Vim Help section on the home page for 2009.
December 2009
Edit
- Press J to join lines, or gJ to join with no extra spaces. :help J
- Use :set nojoinspaces to get only one extra space with J. :help 'joinspaces'
- Use 'B' and 'M' in 'formatoptions' to control spacing with multi-byte characters when joining lines. :help fo-table
November 2009
Edit
- The built-in printf() supports strings and numbers, including floating point. :help printf()
- Substitute can replace matches with an evaluated expression: :s/.../\=.../. :help sub-replace-expression
- In :s/.../\=.../ the expression can use submatch(0) to get the matched text. :help submatch()
October 2009
Edit
- When splitting a window, local options are copied to the new window. :help local-options
- The 'equalalways' option affects window sizing when splitting. :help 'equalalways'
- And the 'eadirection' option determines how 'equalalways' is interpreted. :help 'eadirection'
September 2009
Edit
- In normal mode, pressing Ctrl-^ edits the alternate file. :help CTRL-^
- In insert mode, pressing Ctrl-^ toggles :lmap language mappings. :help i_CTRL-^
- The command :language displays the current language (locale). :help :language
August 2009
Edit
- The command :ka (useful in a script) sets mark a. :help :k
- Using g`" jumps to the last known position in a file without changing the jump list. :help g`
- Typing :keepmarks '<,'>!filter replaces the last selected lines with output from a filter, while keeping marks. :help :keepmarks
July 2009
Edit
- Vim's clever tricks are in chapter 12. :help usr_12.txt
- The 'shiftround' option keeps indentation at multiples of 'shiftwidth'. :help 'shiftround'
- The 'smartindent' option performs smart autoindenting when starting a new line. :help 'smartindent'
June 2009
Edit
- Press Ctrl-w then o to see only the current window. :help CTRL-W_o
- Press Ctrl-w then r to rotate windows in a row or column. :help CTRL-W_r
- Press Ctrl-w then K to move the current window to the top (full width). :help CTRL-W_K
May 2009
Edit
- In a range, . is the current line, and .+5 is 5 lines after the current line. :help :range
- Typing 6 then :s/old/new/g is interpreted as :.,.+5s/old/new/g :help N:
- Command :silent 'a,'bs/old/new/g will substitute in a range, swapping the first and last lines if necessary. :help E493
April 2009
Edit
- Use :set rl! to overcome boredom. :help 'rl'
- Or try :g/^/m0 :help :g :help :m
- And ggg?G can be just as useful. :help g?
March 2009
Edit
- Press R to enter Replace mode to overstrike characters. :help R
- Press gR to enter Virtual Replace mode to overstrike screen space. :help gR
- Press 3S to delete 3 lines and start insert (substitute lines). :help S
February 2009
Edit
- Read how to recover after a crash, before you need to! :help crash-recovery
- The 'backupcopy' option determines how files are written if backups are used. :help 'backupcopy'
- The 'backupext' option can be changed in an autocommand to keep lots of backups. :help 'backupext'
January 2009
Edit
- The :le command left-aligns all visually-selected lines. :help :left
- Format specified lines by typing gq followed by a motion command. :help gq
- gq uses 'formatexpr' or 'formatprg' or 'formatoptions'. :help 'formatexpr' :help 'formatprg' :help 'formatoptions'