meder omuraliev
meder omuraliev

Reputation: 186552

VIM: Delete+Paste in one "command"?

I'm doing a lot of text manipulation between multiple files that requires a lot of yy, dd and ping. This may sound crazy but is there some shorter way of doing dd and p in one go? Maybe even with a plugin?

Upvotes: 6

Views: 896

Answers (3)

mpobrien
mpobrien

Reputation: 4972

I typically just use:

Shift+v (selects the whole line)

and then

p (pastes over the selected line with your current register)

Upvotes: 6

michael
michael

Reputation: 11847

I just had a go at expanding peter's answer to include a visualline mapping so you can do multiple lines at once. I personally prefer ctrlj / k but you can do whatever you like. Enjoy.

nnoremap <c-j> ddp
nnoremap <c-k> ddkP
vnoremap <c-j> dp'[V']
vnoremap <c-k> dkP'[V']

Upvotes: 1

Peter
Peter

Reputation: 132157

You can just make a map:

:map J ddp

and then J (or whatever you want) will do the combined operation.

Incidentally, I always map D to dd, since I delete entire lines much more often than to the end of the line. That makes it easy to use Dp to do your task.

Upvotes: 8

Related Questions