me looking so small in this world

15 2007f January, 2007

search and replace text in vi

Filed under: linux, vi — rudyegenias @ 2:56 pm

Got some problems executing this command in vi:

:s/dapper/edgy/c

which I expect to search and replace text with confirmation when I have edited my ubuntu sources.list

The problem is solve using the command:

:%s/dapper/edgy/c

or

:.,$s/dapper/edgy/c

Conclusion:

Commands in vi generally starts with what range of line numbers are to be searched/processed.

. represents the current line of file

$ last line of file

^ first line of file (never tried it though you can 1 to be sure)

% represents all lines of the current file.

Enjoy


2 Comments »

  1. Hi.

    In my case, I don’t usually go for /c parameter. As long as I’m sure about the text I’m changing, I use /g.

    You got a cool blog. Keep it up.

    Comment by Dong Calmada — 3 2007f March, 2007 @ 7:26 pm | Reply

  2. Thanks Dong. You too have cool blog. It has been weeks since I have last updated this site.. Your right about the /g.. the article aims to be a primer though. Thanks again.

    Comment by rudyegenias — 5 2007f March, 2007 @ 11:07 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.