Dan Jaouen
Dan Jaouen

Reputation: 849

Vim plugins: calling a function in insert mode inserts function signature into buffer rather than actually calling the function

For example, with VimOrganizer:

* one

Then, when I hit Enter, this is what ends up in the buffer:

* oneorg#tbl#kbd_cr()

Upvotes: 1

Views: 890

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172698

It looks like you're mixing an expression mapping with a standard mapping.

org#tbl#kbd_cr() is a function that returns keystrokes to an expression mapping (:help map-expr). <SNR>17_AutoPairsReturn is a (script-scoped) mapping itself. To be able to concatenate the two, use an intermediate mapping for the function:

:inoremap <expr> <SID>org-mapping org#tbl#kbd_cr()
:imap <Enter> <SID>org-mapping<SNR>17_AutoPairsReturn

Upvotes: 3

silverjam
silverjam

Reputation: 400

At least for the .vimrc, there are different modes to map a key, for example, imap for insert mode, nmap for normal mode. If you map something with imap, it needs to be aware that it's in insert mode and generate commands appropriately, for example:

:inoremap <F2> <C-R>=expand('%:p:h')<CR>

See Mapping keys in Vim for me info.

Upvotes: 0

Related Questions