linux - vim:如何在 vim 可视模式下复制单词,但在可视块模式下粘贴?
问题描述
我想使用 vim 的可视模式复制一个简单的文本,然后使用块模式将其粘贴到多行中。我怎样才能做到这一点。
例子:
//this all lines are commented for debug --
int c = 10;
int a = 2;
uint8 d = 0;
uint8 n = 0;
我想实现:
//this all lines are commented for debug --
//this all lines are commented for debug -- int c = 10;
//this all lines are commented for debug -- int a = 2;
//this all lines are commented for debug -- uint8 d = 0;
uint8 n = 0;
我尝试突出显示评论部分(使用 v right_arrow 组合),然后猛拉 . 现在我希望将这个被拉出的结果粘贴到所有预期行的前面。这不必在行首,我不能使用 I 选项手动输入注释。
解决方案
我会拉出第一行,然后在第一列上进入块可视模式<C-V>
并选择几行,I
nsert before,然后从插入模式(<c-r>"
)粘贴默认寄存器。用顺序的话:
y$<down><home><c-v>4<down>I<c-r>"<esc>
应该做的伎俩。
推荐阅读
- python - 如何在numpy中跨多个轴连接多个数组
- javascript - 使用详细信息和摘要标签作为可折叠的内联元素
- django - 如何使用渲染将数据加载到 Django 模板中,并使用 AJAX 请求过滤加载的数据?
- swagger-ui - 如何使 Swagger UI 中的响应示例与 application/application/vnd.api+json 的实际响应相匹配?
- c# - 获取 Quartz.NET 3.0 中的所有工作
- c++ - 在两个类上协调析构函数,其中一个类需要先清理
- php - 如何使用 php 从网站上的表中抓取数据
- r - 反转数据表中搜索框和输入框的位置
- flutter - Dart 中的类型继承检查仅基于 Type 实例
- flutter - 如何在flutter_web中收集文本输入