Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find in vi question

Status
Not open for further replies.

razalas

Programmer
Apr 23, 2002
237
0
0
US
Does anyone know of a way to load the search string in vi without actually typing the search string at the keyboard?

Usually, if I need to search for a long string, I will use the Windows cut and paste functions to avoid having to retype the search argument. But it would be nice if there were a way to "yank" the search argument directly into the search buffer. Ideally, I'd like to be able to be able to position the cursor at my search argument text, then enter "1wyy" to grab the word at the cursor, and follow that with an "n" to find the next occurrence of the word.

I am using vi on SCO 5.0.6. Maybe this is possible in vi on other versions of Unix, but I haven't found a way to do it on SCO.

Any suggestions? Or do I need to switch to a new editor?

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
Have you considered using sed, the stream editor? sed can be passed a command file.

-------------------------
The trouble with doing something right the first time is that nobody appreciates how difficult it was - Steven Wright
 
John,

No, I have not. Based on my understanding of what sed is, I don't think that is what I am looking for. But I'll look into it.

Thanks

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
:g/search-string/ can be placed in front of several ex commands, and ex underlies vi

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
What I do is to use the cut/paste options on my terminal emulator (usually PuTTY)

Columb Healy
 
I do the same as Columb using our Glink terminal emulator. I think Tinyterm or similar has this capability too.
 
Cut and paste? Why go to all that trouble? ;-)

If you only want to search for a single word, just position the cursor over the word you want to search for and type * (asterisk) to find the next occurrence. Or type # (pound) to search backwards.
 
chipperMDW,

that's exactly the sort of thing I am looking for!!!

Unfortunately, that doesn't seem to work in my version (SCO) of vi.[sad]

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top