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
chicks
  • 332
  • 1
  • 5
  • 13

1 Answers1

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> #/
Vivian De Smedt
  • 16,336
  • 3
  • 18
  • 37