Yep, this is a dummy’s reference… I keep on forgetting the syntax so I might as well put it here for my own reference… 😀
vi is the one, if not the most popular text editor available for a System Administrator on a UNIX and UNIX-like machines.
It has two modes, command and editor mode.
Here are some syntax in using the Search and Replace in ‘vi’.
Search:
The most basic and most easily remembered command for searching is vi is slash or ‘/’ followed by the character being searched. That’s for forward searching. For backward, vi use ‘?’ followed by the string being searched.
To go to the next occurrance of the string being searched, vi use ‘n’ command. Doesn’t matter if your searching forward (from up, down) or backward, from down to top.
Example:
(you have to be in command mode… press ESC first)
/search_string
?search_string
Search and Replace
For search and replace, use the syntax
:%s/original/replaced/g
Make sense?
Any command that begins with a “:” is called a line mode command and performs its duty on the line the cursor is currently on.
The above syntax serves my purpose now… If I want to replace text in certain ranges.. syntax can be found here
wazz up ? kumusta ka pinoy?
keep up the nice postings around here!
vertito
Hi! ayus lang bro! Thanks plenty for your kind words!