# Hokey Pokey



## Niatross (Sep 26, 2012)

The question I have is with the "vi" editor.

The 'vi" paste feature is not doing what I want it to do.

The "p" wants to paste after a line.
The "P" wants to paste before a line.

I want to put my cursor on a line and paste and overwrite all the text on that line.

What do I need to do to make this happen?

PS: Do I need to do the hokey pokey and turn myself around to make this happen or what???


----------



## gpw928 (Sep 27, 2012)

Hi,

"ddP" will do what you want.

BSD distributions used to come from Berkeley with a vi tutorial titled "An Introduction to Display Editing with Vi" by Bill Joy, et. al.  Suggest you google it and then spend an afternoon practising.

Cheers,


----------



## drhowarddrfine (Sep 27, 2012)

http://docs.freebsd.org/44doc/usd/12.vi/paper.html


----------



## Niatross (Sep 28, 2012)

drhowarddrfine said:
			
		

> http://docs.freebsd.org/44doc/usd/12.vi/paper.html



Thanks for the help, but this is no help.


----------



## Niatross (Sep 28, 2012)

gpw928 said:
			
		

> Hi,
> 
> "ddP" will do what you want.
> 
> ...



I think you misunderstood what I stated (above).  I have some text on line 1. I type "yy" to copy it. I move my cursor down to line 5 and want to paste it right over the text that is on line 5.

How do I do it?

Again...
I want to OVERWRITE line 5 with line 1. I DO NOT want to delete the data on line 5 before I paste line 1. I want to OVERWRITE line 5.

I DO NOT want to paste it above or below line 5.


----------



## Niatross (Sep 28, 2012)

This the hokey way of doing it:

"ayy

dd"ap

Any better ideas?


----------



## gpw928 (Sep 28, 2012)

Hokey is in the eye of the beholder.

There are no primitives in vi to do exactly what you ask with a single command.

However there are many satisfactory ways of achieving the desired outcome.

Your proposal above will only work if line 5 is the last in the file. 

One precise solution is "1GY5Gp-dd".

Cheers.


----------



## Niatross (Sep 28, 2012)

gpw928 said:
			
		

> Hokey is in the eye of the beholder.
> 
> There are no primitives in vi to do exactly what you ask with a single command.
> 
> ...



I can't believe what you have to type in order overwrite a line in the "vi" editor. I feel like we're doing morse code. You have to remember something. The "vi" editor was made when the hippies were coming off a decade of drugs. Bill Joy was on acid when he created it in 1976.


----------



## ChalkBored (Sep 30, 2012)

Niatross said:
			
		

> I can't believe what you have to type in order overwrite a line in the "vi" editor. I feel like we're doing morse code. You have to remember something. The "vi" editor was made when the hippies were coming off a decade of drugs. Bill Joy was on acid when he created it in 1976.




```
map pp p-dd
```

Then use pp to overwrite the line.

Stick that in whatever .config file your version of vi/vim uses


----------



## UNIXgod (Sep 30, 2012)

There is always going into ex mode and using substitute.


----------



## wblock@ (Sep 30, 2012)

Contrary to popular belief, editors besides vi(1) do exist.


----------

