All articles, tagged with “vim”


I can’t remember how to search and replace a string in Vim!

I’m not going to explain what all the options are, or tell you what each part of the command means. I’m just going to give you an example so that you can remember it. You can look up the details somewhere else.

This example will replace every instance of <find string> with <replace string> in the whole file.

%s$<find string>$<replace string>$g

[ Read More | 0 comments | 0 pingbacks | , ]

How do I change colors in vim?

A couple colors in vim are too dark for me to read on my black background terminal—especially the comments, but the :set bg=dark (or :set background=dark) command doesn’t have an effect. I am thankful to Lee J Carmichael who provided these simple instructions in an archived mailing list post (To: freebsd-questions, Subject: Re: Changing comment color in vim, Date: Mon, 10 Mar 2003 06:56:14 -0800):

Add to your ~/.vimrc the line:
hi Comment ctermfg=darkmagenta

You can see what other colors are available by entering these two lines in vim:
:e $VIMRUNTIME/syntax/colortest.vim
:so %

Other syntax types that you can set the coloring for are: Comment, Constant, Special, Identifier, Statement, PreProc, Type, and Ignore.

[ Read More | 0 comments | 0 pingbacks | , ]

Email: Password:
OpenID URL:
Forgot Login? Close