Saturday, October 10, 2015

Re: :m without jumping

On Wednesday, October 7, 2015 at 4:34:18 AM UTC-5, Jan wrote:
> Is it possible to move a line or lines, with :m, and not have the cursor jump to that new location, ie. to have it stay where it is?

I'm a writer, not a coder, but I use this to move a single line (which usually means a whole paragraph for me in Markdown) to the bottom of the file and then come back to the same neighborhood. Also opens the fold if there is one. A Vim wizard will probably show us how to do it in Vimscript.

" Line To Bottom:
" Moves a single line of text to bottom.
" ,e mneumonic "end"
" Put cursor on line you want to move.
" kmz - k moves up one line and mz drops a mark z
" j moves back to the line that needs moving
" :m (move line), $-2 (to two lines before end $),
" zo opens the fold if it's closed
" o (add a blank line below)
" <Esc> re-enter normal mode, 'z (goback to mark z)

nnoremap ,e kmzj:m $-2<cr>zo<Esc>'zzo

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment