3

Whenever I input # in Neovim I get delay. I tried to fix this with

nnoremap # <nop>
vnoremap # <nop>

In my init.vim but that seemed to only fix it in non .tex environments. I assume this has something to do with the plugins I am using. Specifically, I suspect this is an issue with vimtex / ultisnips.

Question: Can someone help me diagnose where this is comming from and to disable it?

Extra: To :verbose imap #

I am getting

i  #B          *@vimtex#imaps#wrap_math("#B", vimtex#imaps#style_math("mathbb")
)
        Last set from ~/.config/nvim/pack/plugins/start/vimtex/autoload/vimtex/
imaps.vim line 119
i  #-          *@vimtex#imaps#wrap_math("#-", vimtex#imaps#style_math("overline
"))
        Last set from ~/.config/nvim/pack/plugins/start/vimtex/autoload/vimtex/
imaps.vim line 119
i  #c          *@vimtex#imaps#wrap_math("#c", vimtex#imaps#style_math("mathcal"
))
        Last set from ~/.config/nvim/pack/plugins/start/vimtex/autoload/vimtex/
imaps.vim line 119
i  #f          *@vimtex#imaps#wrap_math("#f", vimtex#imaps#style_math("mathfrak
"))
        Last set from ~/.config/nvim/pack/plugins/start/vimtex/autoload/vimtex/
imaps.vim line 119
i  #b          *@vimtex#imaps#wrap_math("#b", vimtex#imaps#style_math("mathbf")
)
        Last set from ~/.config/nvim/pack/plugins/start/vimtex/autoload/vimtex/
imaps.vim line 119
i  #/          *@vimtex#imaps#wrap_math("#/", vimtex#imaps#style_math("slashed"
))
        Last set from ~/.config/nvim/pack/plugins/start/vimtex/autoload/vimtex/
imaps.vim line 119
4
  • Do you have the delay in normal mode or in input mode? Commented Oct 8, 2023 at 12:51
  • 1
    Hi. The input is in input mode. For example when I type #, nvim displays it with the cursor like |# waits one second and becomes #| Commented Oct 8, 2023 at 12:53
  • How to debug my vimrc, How to debug a mapping
    – D. Ben Knoble
    Commented Oct 8, 2023 at 14:43
  • Do you still have something open in your question? How can we help you further? Otherwise may be could you accept one solution using the v button next to the arrow voting buttons. It allow the quesrion to rest :-) Commented Oct 8, 2023 at 20:07

1 Answer 1

2

This probably means that you have a mapping or several mapping that starts with # and that Vim is waiting you type another key to solve the ambiguity.

To know more about the mapping that starts with # you can use:

:verbose nmap #

If the problem you have is input mode you can use:

:verbose imap #

VimTex comes with several mapping in insert mode that starts with #

  • #B
  • #b
  • #c
  • #f
  • #-
  • #/

More information about the insert mode mapping that comes with vimtex with :help vimtex-imaps.

You can list all the vimtex insert mode mapping with:

:VimtexImapsList

Unless you deactivate all of them when you hit # you have to type an additional character such that Vim knows what to do.

You can disable these mapping by setting the following variable into your init.vim file:

let g:vimtex_imaps_disabled = ['b', 'B', 'c', 'f', '/', '-']

That should solve your problem.

But if you fail to prevent them to be created you can delete them by adding a ~/.config/nvim/after/ftplugin/tex.vim with the following content:

~/.config/nvim/after/ftplugin/tex.vim:

iunmap <buffer> #B
iunmap <buffer> #b
iunmap <buffer> #c
iunmap <buffer> #f
iunmap <buffer> #-
iunmap <buffer> #/
14
  • 1
    Hi I am afraid this doesn't work. I have added an additional comment bellow my question. I can also provide a gif if nothing comes to mind as to what could be causing it. Commented Oct 8, 2023 at 12:54
  • 1
    Of course. When I execute I get No mapping found. Commented Oct 8, 2023 at 13:05
  • 1
    Add what is the output of :verbose imap #? Commented Oct 8, 2023 at 13:09
  • 1
    Hi. Appologies for the delay. I added the above to my init.vim but I still get errors. They are too long for the comment so I have added them to the question. Commented Oct 8, 2023 at 21:32
  • 1
    I assume for some reason the above command is not dissabling the options Commented Oct 8, 2023 at 21:34

Your Answer

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

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