Does Vim move / copy the line to the end of the file without moving the cursor?

I often use :.m$ to move or :.t$ to copy the current line to the end of the file. Sometimes it would be easier if the cursor does not go to the end of the file or the target location of the move / copy command. Is there any opportunity for this?

+7
vim
source share
1 answer

try these two mappings:

 "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 will be changed to the text of the next line, since the original line of text has disappeared. But he sits on one line (number).

If you want the anonymous register ( " ) to be untouched, I think we need to write a function for it.

+7
source share

All Articles