I looked for a way to turn J into an operator and found this
old post which describes how to do just that:

<https://groups.google.com/forum/#!msg/vim_use/0hsMb4u-kUo/rObfv5MC0s8J>

nnoremap J :set operatorfunc=Joinoperator<CR>g@
nnoremap gJ :set operatorfunc=GJoinoperator<CR>g@
onoremap J j
func! Joinoperator(submode)
        '[,']join
endfunc
func! GJoinoperator(submode)
        '[,']join!
endfunc

so I can do JJ to join just two lines, but also use J with a motion.

I'm generally satisfied, but there is one irritation: with
vanilla J the cursor ens up at the point where the lines were
joined, which is handy if the joined lines were line comments or
email quotes, because then you can just hit x once or twice to
remove the comment/quote indicator which now ends up in the
middle of the joined line. With this hacked JJ the cursor ends up
at the left margin, so I have to do f>xx to remove the now
misplaced comment/quote marker. I would be very grateful for a
way to get that JJ to jump to the 'join point'!

(I'm aware that a * which simply searches for the WORD under the
cursor would do the trick, so anything in that direction would be
helpful too.)

TIA,

/bpj

--
--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to