2

I'm trying to write a mapping that will let me move around 'common' insertion points in a line when in insert mode. For example, I have the delimitMate plugin - so typing a opening delimiter automatically closes the delimiter and puts me in between. Once I've typed the text that goes inside, I usually want to jump to the end of the delimiter and stay in insert mode. Taking this forward, for a function like below

 $("#someid").live("someevent", function (param1, param2) {

What I'd like is a insert mode mapping that lets me jump to after the first of any of the following delimiter chars (quote, double quote, parens, and/or EOL) and cycle over these points.

Checked VIM documentation for search - the \%l operator allows to restrict over a specific line number. I tried \%.l (. being current line ) - but this doesn't work. Any ideas?

:exe  "/\\%" . line(".") . "l[{}()\"':=\\[\\],]"

seems to work - but doesn't move the cursor to the match.

0

1 Answer 1

1

Got this to work with the following.

inoremap <C-e> <C-o>:call search("\\%" . line(".") . "l[{}():=\\[\\]\.,]","We")<cr>

This moves the cursor to the matches on the current line, but there are two things that don't work well:

  1. there's a long pause everytime I hit the key
  2. It drops me in Ins mode before the matching character instead of after as I'd like.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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