views:

53

answers:

1

In Vim 7, Ctrl-X Ctrl-O shows a list of possible values but I find this sequence of keys to be too long when I frequently use the autocomplete feature. For instance, in an HTML file, I'd like to see the list automatically popup after I type a < followed by one or two letters. In a CSS file, I'd like to see the list after I hit the ":" key. Is there a way to set this up?

+1  A: 

To activate the omnicompletion on typing a ":" you can use the following mapping.

imap : :<c-x><c-o>

The disadvantage is that each time you press ":" omnicompletion will be activated, even when typing ":" in comments or in any other context in which you do not want omnicompletion.

I have mapped ctrl-space to active omnicompletion:

imap <c-space> <c-x><c-o>

This gives me the choice to activate omni whenever I need it.

Habi
I'd have to agree with Habi on this one. It's better to specifically trigger omni-completion when you need it than to have it automatically triggered. Omni-completion should be a tool to help you, not a crutch that you rely on.
jamessan
I would say, just restrict it to the CSS filetype (as the only time you'll type : is when you want those options.`au FileType css imap : :<c-x><c-o>`
sleepynate
@sleepynate Thanks, this is exactly what I wanted!
geoffeg