我想使用 vim 的可视模式复制一个简单的文本,然后使用 block 模式将其粘贴到多行中。我怎样才能做到这一点。
例子:
//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 选项手动输入评论。
最佳答案
我会拉出第一行,然后在第一列进入 block 视觉模式 <C-V>
并选择几行,I
nsert 之前,并从插入模式 (<c-r>"
) 粘贴默认寄存器。换句话说:
y$<down><home><c-v>4<down>I<c-r>"<esc>
应该可以解决问题。
关于linux - vim:如何在 vim 可视模式下复制一个单词,但在可视 block 模式下粘贴它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60872715/