Nerdy Drunk

Drunk on technology

User Tools

Site Tools


linux:vim

Vim

Syntax Highlighting

To enable syntax highlighting for unique file names edit:
/home/USERNAME/.vimrc

au BufNewFile,BufRead FILE.NAME      setf SYNTAX

Syntax files are in:
/usr/share/vim/vim74/syntax/


Search and Replace

Find each occurrence of 'foo' (in all lines), and replace it with 'bar'.

:%s/foo/bar/gc
  • Remove “%” to search only a single line.
  • Remove “g” to search only for first instance.
  • Remove “c” to not ask for confirmation.
  • Add “i” to make case insensitive.
  • Add “I” to make case sensitive.

Change only whole words exactly matching 'foo' to 'bar'; ask for confirmation.

:%s/\<foo\>/bar/gc

http://vim.wikia.com/wiki/Search_and_replace

linux/vim.txt · Last modified: 2022/07/21 10:41 by 127.0.0.1