I recently moved from vim-latex-suit to vimtex. In vim-latex-suit, there was this awesome feature that when I press Ctrl-j, it jumps to where <++> is and replace that to the cursor.

To clarify,

I want

blah blah blah <++>

to be

blah blah blah |

where | is the position of the cursor.

I would like to implement the same feature by some command in .vimrc. Any ideas?

1 Answer 1



nnoremap <C-j> /\V<++><CR>cgn
" if you want insert-mode versions, too
imap <C-j> <esc><C-j>

Or, if you don't want to mess with search history,

nnoremap <C-j> :call search('\V<++>')<CR>cf>
" insert-mode
imap <C-j> <esc><C-j>
  • Sorry, I tried but this answer didn't have the part > <++> is and replace that to the cursor. It jumps to where <++> is, but it doesn't clear <++> and replace that with the cursor
    – Tom
    Nov 10, 2021 at 21:20
  • Try cgn after a search. You could alternately start select mode with something like gh<C-o>//e<CR>. cgn has the advantage that it is (a) dot-repeatable and (b) after invoking the mapping or search, you can just type cgn for each instance you want to change.
    – D. Ben Knoble
    Nov 10, 2021 at 21:23
  • nnoremap <C-j> :call search('\V<++>')<CR> cgn ?
    – Tom
    Nov 10, 2021 at 21:24
  • 1
    @Biggybi or save yourself some duplication with :imap <C-j> <esc><C-j> :)
    – D. Ben Knoble
    Nov 11, 2021 at 13:29
  • 1
    @Biggybi I edited the answer and now it does what I want to do! Thank you everyone!
    – Tom
    Nov 11, 2021 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.