Vim移动/复制行到文件末尾而不移动光标?

vbd*_*vbd 10 vim

我经常使用:.m$移动或:.t$将当前行复制到文件的末尾.有时,如果光标不会跳转到文件末尾或移动/复制命令的目标位置,则会更容易.它有选择吗?

Ken*_*ent 11

尝试这两个映射:

"move current line to the end of buffer without moving cursor
nnoremap <leader>mv ddGp``

"copy current line to the end of buffer without moving cursor
nnoremap <leader>cp YGp``
Run Code Online (Sandbox Code Playgroud)

请注意,对于这种move情况,光标位置将更改为下一行的文本,因为原始文本行已经消失.但它坐在同一条线(数字)上.

如果您要求匿名register(")不受影响,我认为我们需要为它编写一个函数.