简体   繁体   中英

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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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