Linux Today: Linux News On Internet Time.
Search Linux Today
Linux News Sections:  Developer -  High Performance -  Infrastructure -  IT Management -  Security -  Storage -
Linux Today Navigation
LT Home
Contribute
Contribute
Link to Us
Linux Jobs


More on LinuxToday


Advanced Tips for Search-and-Replace in Linux

Sep 29, 2009, 18:34 (0 Talkback[s])
(Other stories by Juliet Kemp)

"Search-and-replace is likely to be the operation you'll most often use regexps for in an editor. First let's look at a straightforward non-regexp search-and-replace. Let's say that you've just decided to rename a variable from foo to fooOne. In Vim, hit Esc for command mode, then use this command:

":%s/foo/fooOne/g

"% means that the operation should be carried out throughout the whole document. The important part is s/foo/fooOne/, which means "replace every instance of 'foo' with 'fooOne'". The final g means "global"; without this you'll just replace the first instance on every line, but with it, you replace every occurrence."

Complete Story

Related Stories: