Vim
Table of Contents
- 1. Format long lines of text
- 2. Vimdiff without context
- 3. Search for selected text
- 4. Show setting current value
- 5. Make highlighted text lowercase/uppercase
- 6. New lines
- 7. Append
fooat the end of every line containingbar - 8. Substitute every instance of
foowithbaron lines starting with^bazin the buffer - 9. Substitute every instance of
fooin the buffer withbar - 10. List sourced scripts by loading order
- 11. References
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
Venter visual modeyyank the selection into the"register/enter search modeC-r "insert text from"registerRETpress 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
- https://vimdoc.sourceforge.net/htmldoc/visual.html#visual-use
- https://vimdoc.sourceforge.net/htmldoc/change.html#uppercase
- https://vimdoc.sourceforge.net/htmldoc/change.html#lowercase
Venter visual mode- select lines
u/Uto switch between lowercase and 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