vim - 插入文本后移动光标

ade*_*kcz 2 vim

插入(通过粘贴)多行文本后,如何移动光标?在做内联插入(粘贴),p并且P工作得很好.但是,如果我粘贴多行文字,我的光标不管pP移动到新的文本的顶部.

如何将光标留在新文本之后pP

Ken*_*ent 11

使用标记是一种方式.但是p or P,如果你想将光标留在新粘贴的文本之后,则有内置版本gp

:h gp 细节

["x]gp          Just like "p", but leave the cursor just after the new
            text.  {not in Vi}


["x]gP          Just like "P", but leave the cursor just after the new
            text.  {not in Vi}
Run Code Online (Sandbox Code Playgroud)


Ran*_*ris 5

您希望使用]标记移动到粘贴文本的末尾.摘录摘自:help ']:

After executing an operator the Cursor is put at the beginning of the text
that was operated upon.  After a put command ("p" or "P") the cursor is
sometimes placed at the first inserted line and sometimes on the last inserted
character.  The four commands above put the cursor at either end.  Example:
After yanking 10 lines you want to go to the last one of them: "10Y']".  After
inserting several lines with the "p" command you want to jump to the lowest
inserted line: "p']".  This also works for text that has been inserted.
Run Code Online (Sandbox Code Playgroud)