To implement your stated use case, the :imap ..<any> ..<any>
would leverage Vim's built-in 'timeoutlen'
; it's implementation wouldn't be so outrageous, there's only a limited set of available keys and you can use metaprogramming with a :for
loop to build all these mappings. The biggest challenge here is enumerating all desired keys.
However, I doubt that this would be very useful. The completion popup would only open after that delay, so it will slow you down (unless you only intend to trigger that mapping if you're contemplating about the possible values, anyway) - completion is as much about saving typing than it is about showing alternatives.
As an alternative approach, I'd home in on try use Omnicoplet to find fields in 1 is nonsense. With a :help :map-expression
, you can check the text before the cursor, and then either trigger completion (without delay!) or (e.g. in case of a digit) just return a literal .
there. That condition can be as complex as you'd like (you could even query the syntax group and leverage syntax parsing of identifiers vs. other stuff), and should "do what I mean" in many cases.
For those special exceptions (that will always exist), I personally find it okay to actively avoid triggering the mapping, either by making a short pause when typing (.
<pause> .
in your case), or escaping one of the characters via i_CTRL-V
: .<C-v>.
inoremap <C-O> <C-x><C-o>
? By the way, you really should usenoremap
versions of mappings. Look into that:h 'timeoutlen'
and:h 'ttimeoutlen'
, however these are global settings they can't be applied to only one mapping. (I know that we already have a question about that, I'll have to find it)