开发者

VIM: Delete+Paste in one "command"?

I'm doing a lot of text manipulation between multiple files that req开发者_JAVA百科uires 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?


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.


I typically just use:

Shift+v (selects the whole line)

and then

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


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']
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜