Skip to content

vi editor sting search and replace

July 24, 2010

/string        search forward for string (end with Enter)
     ?string        search backward for string (end with Enter)
     n              repeat the last search (``next search'')
          :s/s1/s2       replace (``substitute'') (the first) s1 in this line by s2
     :lr/s/s1/s2/g  replace all instances of s1 in the line range lr by s2                     (lr is of form `a,b', where a and b are either explicit

Advertisements

From → Unix

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: