MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
August
Sun Mon Tue Wed Thu Fri Sat
 
22
     
2016
Months
Aug


Mon, Aug 22, 2016 11:45 pm

Substituting characters for a matched regular expression in vi

The vi editor is a screen-oriented text editor that supports regular expressions for pattern matching and character substitution. Vim which stands for "Vi IMproved" is a clone of vi and recognizes similar commands.

If you want to replace or insert characters at the beginning of a line, the line beginning is represented by the caret character, i.e., ^ (Shift-6 on a standard computer keyboard), and line endings are represented by the dollar sign character, i.e., $.

E.g., the following quote has three occurences of the word "us". If I wanted to replace only the "us" at the end of the line with "ourselves", I could hit the colon key while not in vi's insert mode, which would give me a colon prompt and then enter s /us$/ourselves/ which would replace the occurence of "us" at the end of the lne with "ourselves".

What lies behind us and what lies before us are tiny compared to what lies within us

~ Ralph Waldo Emerson

[ More Info ]

[/software/editors/vi] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo