1

I'm having a problem with using imaps with vimtex (i.e they don't work).

To test the issue I went to .vim/plugged/vimtex/test/examples/minimal and started vim -u minivimrc.

Typing `a (which is a AltGr-7 and the "a" key, since I have a Hungarian keyboard) doesn't do anything.

If I manually set this:

:imap `a \alpha

then typing `a expands to \alpha, so I am really unsure what I am doing wrong. I quite new to vim, so maybe I just totall misunderstood how I should be using it.

edit I didn't know how to capture the output, so I made a screenshot of the output of :imap `a enter image description here

3
  • Is the original mapping backtick-a or à ? In terminal vim, I cant use my alt-backtick-a to insert à, since the terminal doesnt understand it
    – D. Ben Knoble
    Dec 2, 2019 at 14:07
  • Not totally clear from your post... Are you trying to use a mapping `a registered by vimtex and that's not working? If so, with vimtex loaded, can you take a look at what :imap `a says? It should allow you to inspect an existing mapping... I don't think your Hungarian keyboard layout has anything to do it, as long as the AltGr-7 key combination is producing a backtick character, that should be fine...
    – filbranden
    Dec 2, 2019 at 15:21
  • it definitely looks as a a. I mentioned the keyboard, because in i3` I had some weird stuff going in with shift+3 being my plus sign :)
    – fbence
    Dec 2, 2019 at 19:21

1 Answer 1

2

Please note that the `a mapping is using vimtex#imaps#wrap_math(), which only expands to the right hand side when typed in a math context. (See the code in vimtex.)

So, this mapping will only expand to \alpha if typed in a math context, such as within $...$, inside a \begin{equation}...\end{equation} block, or in a similar context that is considered to be a "math" context.

(vimtex uses the syntax engine to determine what is a "math" context, see definition of is_math(). In particular, that means you need to have syntax enable to be able to use that, since otherwise it won't recognize the "math" blocks correctly and will never apply the expansion.)

1
  • 1
    perfect, thanks!
    – fbence
    Dec 3, 2019 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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