本文介绍了在可视模式下在行首粘贴数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用SHIFT + V选择行,然后使用上下左右键选择行,然后使用y复制它们(猛拉它们)并使用p(放置).

I can select lines using SHIFT + V, then selecting lines using up down left right keys, then copy them using y (yank them) and paste them using p (put).

我可以类似地使用CTRL + V选择数据块,然后使用上下左右键选择行,然后使用y复制它们(猛拉它们)并粘贴它们使用 p(放置).

I can similarly select data block using CTRL + V, then selecting lines using up down left right keys, then then copy them using y (yank them) and paste them using p (put).

但是当我使用 p 粘贴数据块时,它总是在当前光标位置之后粘贴数据.这意味着,如果我想粘贴到行首,它将不起作用 - 它会在第一个字符之后复制数据.那么如何在vim可视化模式下将数据块粘贴到行首呢?

But when I am pasting data blocks using p, it always pastes data after the current cursor location. Which means, if I want to paste to the beginning of lines, it won't work - it copies the data after the first character. So how can I paste data block at the beginning of a line in vim in visual mode?

目前我通过在第二个光标位置粘贴来实现这一点,删除行首的字符,然后将它们粘贴到先前粘贴的块之后.

Curently I do this by pasting at the second cursor location, deleting the characters at the beginning of line, and then pasting them after the previously pasted block.

推荐答案

选择并拉取您正在执行的操作,粘贴时按 P 而不是 p." 寄存器中的内容将放在您的光标之前.

select and yank as what you are doing, when you paste press P instead of p. The content in " register will be put before your cursor.

还要注意:使用p或P,粘贴后光标会停留在刚刚粘贴内容的开头.如果您希望光标位于粘贴文本的末尾,请使用 gp 或 gP.

also note that: with p or P, after your pasting, the cursor will stay at the beginning of the just pasted content. If you want your cursor to be at the end of pasted text, use gp or gP.

这篇关于在可视模式下在行首粘贴数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-17 00:17