在vim中剪切和粘贴多行 [英] Cut and paste multiple lines in vim

查看:36
本文介绍了在vim中剪切和粘贴多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Mac 10.7.2 上运行 vim 7.3,但在剪切和粘贴几行时遇到了一些问题.

I'm running vim 7.3 on a Mac 10.7.2 and I'm having some trouble cutting and pasting several lines.

在我的旧 Linux 设置(被盗,所以我不知道版本)上,我可以多次输入dd",然后p"会将它们全部拉回来.例如:键入:dd dd",将删除两行.现在输入p",两行都被粘贴回缓冲区.

On my old Linux setup (which was stolen so I don't know versions), I could type "dd" multiple times and then "p" would yank all of them back. For example: type: "dd dd" and two lines would be deleted. Now type "p" and both lines are pasted back into the buffer.

我知道我可以通过输入2dd"然后输入p"来完成我想要的——但我希望能够dd"输出行而无需提前计算行数.

I know I can accomplish what I want by typing "2dd", and then "p" - but I would like to be able to "dd"-out lines without counting the number of lines ahead of time.

有什么想法吗?

推荐答案

您是否考虑过使用 视觉模式?

你可以去:

  • V
  • 选择您要剪切的所有内容,无需计算
  • d
  • 转到您要粘贴的位置
  • p

这应该产生的击键次数大约是 dd 方法的一半,因为您每行按一个键而不是两个键.如果您使用 5j(或类似工具)一次选择多行,则可获得加分.

This should yield approximately half as many keystrokes as the dd method since you press one key per line rather than two. Bonus points if you use 5j (or similar) to select multiple lines at a time.

这篇关于在vim中剪切和粘贴多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆