简体   繁体   English

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

[英]Vim move / copy line to end of file without moving cursor?

I often use :.m$ to move or :.t$ to copy current line to the end of the file. 我经常使用:.m$移动或:.t$将当前行复制到文件末尾。 Sometimes it would be easier if the cursor won't jump to end of file or target location of the move / copy command. 有时,如果光标不会跳转到文件末尾或移动/复制命令的目标位置,则会更容易。 Is there an option for it? 它有选择吗?

give these two mappings a try: 尝试这两个映射:

"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``

note that for the move case, the cursor position would be changed to the text of next line, since the original line of text has gone. 请注意,对于move情况,光标位置将更改为下一行的文本,因为原始文本行已经消失。 But it sits on same line (number). 但它坐在同一条线(数字)上。

If you required the anonymous register ( " ) to be untouched, I think we need write a function for it. 如果您要求匿名注册( " )不受影响,我认为我们需要为它编写一个函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM