I sometimes add abbreviations for local files or projects.

For example having:


Instead of typing PREFIX_ I map it to something, for example PP or P1, P2, ... etc.


How can I open completion for the PREFIX_ in addition to the abbreviation swap when using abbr<SPACE>?

PS: Using abbr<C-]> would make it simpler, but rather type abbr<SPACE> over abbr<C-AltGr-9> which is the case on my keyboard.

1 Answer 1

  1. Add <C-n> to the mapping.
  2. Trim away the added space. Has to be done after completion keys.
:iab PP PREFIX_<C-n><C-p><C-R>=trim(getcharstr(0))<CR>

" or to keep first selected:

:iab PP PREFIX_<C-n><C-R>=trim(getcharstr(0))<CR>

The trim(getcharstr(0)) is a shorter version of Eatchar() as described in :h abbreviations

Should work for both ABR<SPACE> and ABR<C-]>

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.