Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to ViM customization. I am almost done getting autocompletion to work as I would like. Here is the line of interest:

inoremap <expr> i (pumvisible() ? '' : 'i<C-n>') . '<Down>'

Notice that it captures i and then still types it (and then sends <C-n>). I would like for this to work like a regular expression. How can I get this to work with any word character? I'd rather not have several copies of this each for a different character.

share|improve this question
up vote 2 down vote accepted

There are no wildcards in mappings; you'd have to create all those mappings with a loop:

for i in split('abcdefg...', '\zs')
    execute printf("inoremap <expr> %s (pumvisible() ? '' : '%s<C-n>') . '<Down>'", i, i)
endfor

Please note that there are plugins that achieve auto-completion as you type (what you seem to attempt here); I use AutoComplPop - Automatically opens popup menu for completions

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .