1

When one triggers a completion, vim guesses what was the expression (behind the cursor) that you want to complete. I don't fully understand the logic, but it seems that it assumes that the expression is a sequence of alphabetic chars+some additional.

Suppose I have a graph named "G_{walk}" (I do have - latex). I want to refer to it.

I can trigger a completion that would recognize it when I type G_<c-x><c-n>. But if I type G_{<c-x><c-n>, it regards whatever that follows { as a completely different expression and it won't find "G_{walk}".

So, how can I control the expression? Sometimes I just want it to ignore all its stupid rules, and complete from the moment I press a key and until I tell it to stop. Can it be done?

Thanks.

PS I did read about ins-completion. I don't understand how what I see in syntax list or how omnifunction related to the question I asked about <c-x><c-n> as main example.

2

Most of auto-completion works with keywords, so the set of characters that make up possible completion prefixes and candidates is controlled by the 'iskeyword' setting.

For instance, under :help compl-current you'll find:

If there is a keyword in front of the cursor (a name made out of alphabetic characters and characters in 'iskeyword'), it is used as the search pattern, with "\<" prepended (meaning: start of a word). [...]

Most other types of completion will typically follow the same definition of keywords.

In your particular case, in order to be able to complete G_{walk}, you might want to consider including the curly brace characters in the set of valid keyword characters, which you can do with:

:set iskeyword+={,}

Note that this might affect keyword splitting elsewhere, since { and } are used in TeX/LaTeX for parameters, some words that were previously considered keywords on their own will cease to do so. You should consider this trade-off if you decide to touch the 'iskeyword' setting.

  • 1
    Thanks a lot. I didn't understand that since they wrote: "in front of the cursor" and it seems behind. I think that any keyword/command that is essential to the language appears in omnifunction offered by vimtex and so it won't matter. All seems well anyway. – eyal karni Dec 17 '19 at 11:41
  • 1
    After I have done the change, folding didn't work. But then I installed vim-tex-fold and it got right. – eyal karni Dec 19 '19 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.