1837208 Members
3488 Online
110115 Solutions
New Discussion

vi command

 
SOLVED
Go to solution
Shivkumar
Super Advisor

vi command

Hi,

How to set vi editor using set command in case i want to search some keyword starting from the first line to the last line in the file ?

It should not search starting from the first line again and show the message reach at the end of the line.

I used in the past but forgot now.

Thanks,
Shiv
3 REPLIES 3
Arunvijai_4
Honored Contributor
Solution

Re: vi command

Hi Shiv,

It is wrapscan of searches. You can do it by,

:set ws

If you need any further commands, have a look this link

http://www.cis.ksu.edu/~bhoward/vi/vi60.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
RAC_1
Honored Contributor

Re: vi command

In vi, you just need to do
/search_pattern -> forward search
?search_pattern ->Backward search

Check all your set options, with set all
There is no substitute to HARDWORK
Asif Sharif
Honored Contributor

Re: vi command

Command <=> Search and Replace Action

/text Search for text going forward into the file.

?text Search for text going backward into the file.

n Repeat the search in the same direction as the original search.

N
Repeat the search in the opposite direction as the original search.

ftext
Search for text going forward in the current line.

Ftext
Search for text going backward in the current line.

ttext
Search for text going forward in the current line and stop at the character before text.

Ttext
Search for text going backward in the current line to character after text.

:set ic
Ignore case when searching.

:set noic
Make searching case-sensitive.

:s/oldtext/newtext/
Substitute newtext for oldtext.

:m,ns/oldtext/newtext/
Substitute newtext for oldtext in lines m through n.

&
Repeat the last :s command.

:g/text1/s/text2/text3
Find line containing text1, replace text2 with text3.

:g/text/command
Run command on all lines that contain text.

:v/text/command
Run command on all lines that do not contain text.

Regards,
Asif Sharif
Regards,
Asif Sharif