Linux Today: Linux News On Internet Time.

More on LinuxToday

Advanced Tips for Search-and-Replace in Linux

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


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

"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:


"% 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: