cohama / lexima.vim

Auto close parentheses and repeat by dot dot dot...
995 stars 46 forks source link

Mapping to jump over inserted chars #83

Closed rkiyanchuk closed 5 years ago

rkiyanchuk commented 5 years ago

Is it possible to create a mapping with Lexima that would allow to move over any auto-inserted characters?

Currently you have to type matching symbols to advanced to the next matching char. For example, if I type in def foo("| (where | is the cursor position), in order to get to the end of the line I need to input matching ").

I'm looking for a "meta" mapping that would jump over any character auto-inserted by Lexima. So that I could press, for instance <C-l> twice to get to def foo("")|.

For now I just have a generic workaround for this:

inoremap <C-l> <Right>

This moves over any symbol to the left in insert mode.

I suspect it should possible to achieve with Lexima via leave rule, but couldn't figure out how.

cohama commented 5 years ago

Yes, you can, with undocumented (beta) feature.

inoremap <C-l> <C-r>=lexima#insmode#leave(1, "")<CR>

" or inoremap <C-l> <C-r>=lexima#insmode#leave_till_eol("")<CR>
" or inoremap <C-l> <C-r>=lexima#insmode#leave_all("")<CR>

leave(n, "") moves cursor n character to the right. leave_till_eol("") leave all characters inserted by lexima but will stop before end of line. leave_all("") leaves over new lines.

rkiyanchuk commented 5 years ago

@cohama Wow, awesome! Works perfectly.

Thanks for the tip and for the great plugin!