- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: repeat a same command-set in vi
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2001 06:55 PM
12-20-2001 06:55 PM
For example,
In vi, I need to insert a same word before each word.
As we know, we can insert the word before the first word, then ESC -> w -> . -> w -> . -> .....
Is there any simple ways to repeat these ' w -> . ' at one time?
Thanks in advance !
/Listener
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2001 07:00 PM
12-20-2001 07:00 PM
Re: repeat a same command-set in vi
Once your do an insert of a word, or any string, you can repeat the function by going to the next place where you wish to do it again and press . This is like the repeat key.
-Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2001 07:47 PM
12-20-2001 07:47 PM
Re: repeat a same command-set in vi
What I mean is to repeat a 'command-set', not (use . to repeat) a insert/append/delete/... command.
Such as, is there something like " 10(w.) " to finish my above requirement, just insert the same word before each following words for 10 times.
Sorry to assign a low point which I didn't assign before , but you just repeat what I have mentioned.
:-(
/Discoverer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2001 08:02 PM
12-20-2001 08:02 PM
SolutionSorry I didn't understand your question properly, must be as I'm going on holidays....
Okay, if you have a string called word1 and wanted to replace each occurance of word1 with word23 try
this in 'vi'
:1,$s/word1/word23/g (global all occurance)
:1,$s/word1/word23/ (one on each line)
If you want to insert a string at the beginning
of each line:
:1,$s/^/string//
If this is not what you after exactly have a look at the link, it provides some good working examples of 'vi'
http://www.epcc.ed.ac.uk/tracs/vi.html#intermed4
or
http://www.networkcomputing.com/unixworld/tutorial/009/009.html
HTH
-Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2001 10:12 PM
12-20-2001 10:12 PM
Re: repeat a same command-set in vi
This will repeat the last command 10 times.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2001 10:57 PM
12-20-2001 10:57 PM
Re: repeat a same command-set in vi
You want the the same word to be repeated before every word.
Does this satisfy your requirement:
:1,$s/ / insertedword /g
:1,$s/^/^insertedword /g
Example:
Before inserting:
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
After inserting:
insertedword The insertedword quick insertedword brown insertedword fox insertedword jumps insertedword over insertedword the insertedword lazy insertedword dog.
insertedword The insertedword quick insertedword brown insertedword fox insertedword jumps insertedword over insertedword the insertedword lazy insertedword dog.
Hope this helps. Regards.
Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2001 04:44 AM
12-21-2001 04:44 AM
Re: repeat a same command-set in vi
what you want is called a "macro" in vi.
It works like this:
- you put the keys to be "executed" into a buffer
- you tell vi to execute that buffer with "@".
E.g:
Insert a line like
cwbye
where the stuff in angle brackets is actually keys (your hold down "Ctrl", then press "V", release both of them, and then press the "Esc" key, twice, then the double quote, an "m" and twice a "d").
Now you have the characters "cwbye
Move your cursor to some word you would like to change to "bye" and press "@m".
Te repeat the last macro use "@@".
HTH,
Wodisc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2001 05:53 AM
12-21-2001 05:53 AM
Re: repeat a same command-set in vi
:map t wwcw
this would map the character t to two word commands and a change word command. This can be done with any command.
to get return do
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2001 12:22 AM
12-28-2001 12:22 AM
Re: repeat a same command-set in vi
I love this forum!
Though Tully (& Steven)'s method is not so universal, but I'd like to assigned 10 pts for his total help.
Jeff's is just as what I had though out.
Wodisc's is the same but more expert.
And thanks for Deepak's attendant.
/discoverer