1823271 Members
3096 Online
109648 Solutions
New Discussion юеВ

Re: using vi editor

 
SOLVED
Go to solution
Shivkumar
Super Advisor

using vi editor

Sirs,

I am using vi editor. Just want to copy 2 or 3 words from a line and want to paste it over some other line or new line in the vi editor.

How to do that ?

Thanks,
Shiv
11 REPLIES 11
TwoProc
Honored Contributor

Re: using vi editor

Well, if you know how many characters it is,
just go to the first letter of the string and hit (let's say it's 11 letters):

11x

then go to where you want to paste it, and type:

p

If it's 3 words you want to delete, go to the first letter of the first word and hit:

3dw

then go to where you want to paste it, and type:

p

We are the people our parents warned us about --Jimmy Buffett
Shivkumar
Super Advisor

Re: using vi editor

I want to copy and paste the 2/3 words and Not delete and paste.

Thanks,
Shiv
Mel Burslan
Honored Contributor

Re: using vi editor

make sure you are in the cursor mode (if not sure, hit escape once or more to make sure)

place your cursor at the beginning of the 3 words you want to copy

type 3dw (you will see the 3 words disappearing - now three words are in your clip buffer) if you want to keep them there hit "p" (lower case p) immediately.

now move to the beginning of the location you want to 'paste' them to

hit lower case p again

repeat as necessary
________________________________
UNIX because I majored in cryptology...
Rick Garland
Honored Contributor

Re: using vi editor

I use the 'yank word' feature

Place ther cursor on the 1st character of the 3 words you want to yank.

For 3 words, do '3yw' then move the cursor to where you want the words placed and 'p' to place the words there.

If you are yanking 2 words, '2yw'

The 'p' keystroke is necessary to 'place'.

If you make a mistake, quit the file without saving and try again. To quit without saving.

:q!

Jeff_Traigle
Honored Contributor

Re: using vi editor

Or shorter... use 3yw to copy the three words and then move to where you want to paste them and use the p command.
--
Jeff Traigle
Shivkumar
Super Advisor

Re: using vi editor

Is it possible to copy those 2 words and paste them on existing 2 words on other lines ?
Jeff_Traigle
Honored Contributor

Re: using vi editor

Not that I can think of off the top of my head. There's the s command to substitute (presumably 3sw would substitute what you type for 3 words), but you wouldn't be able to paste anything from the buffer then. Best you can probably get is to paste the words you copied and then delete the words you want then to replace.
--
Jeff Traigle
Yogeeraj_1
Honored Contributor

Re: using vi editor

hi,

maybe a search/replace would work perfectly!

:1,$s/new_word/word_to_replaced/g

hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Muthukumar_5
Honored Contributor

Re: using vi editor

Use Putty client terminal. It is easy to copy and paste in vi editor as,

Select two words
Come to new line and press i
Right click mouse. It will paste it.

To update in other two words with new one then, Press R to change with new words.

hth.
Easy to suggest when don't know about the problem!
Bharat Katkar
Honored Contributor
Solution

Re: using vi editor

Attaching a quick reference of VI.
Thought it would be helpful.

Regards,
You need to know a lot to actually know how little you know
Arunvijai_4
Honored Contributor

Re: using vi editor

Yanking is the best way to do it. Otherwise, use Putty as Muthu specified.

A good guide on VI atatched.

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