Vim

Table of Contents

1. Format long lines of text

2. Vimdiff without context

Only show lines with a diff :set diffopt=filler,context:0

3. Search for selected text

  1. V enter visual mode
  2. y yank the selection into the " register
  3. / enter search mode
  4. C-r " insert text from " register
  5. RET press enter

4. Show setting current value

Add a ? mark after the setting name and it will show its value, e.g. :set expandtab?

5. Make highlighted text lowercase/uppercase

6. New lines

Use \r (return carriage) instead of \n for new lines

this,is,a,line

In Visual line mode, press : and enter this command s/,/,\r/g

this,
is,
a,
line

7. Append foo at the end of every line containing bar

See :help :g

:g/bar/norm A foo

8. Substitute every instance of foo with bar on lines starting with ^baz in the buffer

See :help :g

:g/^baz/s/foo/bar/g

9. Substitute every instance of foo in the buffer with bar

See :help :s and :help :%

:%s/foo/bar/g

10. List sourced scripts by loading order

Run vim --clean to not load any personal configuration, see :help :scriptnames

11. References