My hunch is that you are using vimtex with Ultisnips. While this answer assumes that the behavior comes from vimtex, I recommended to diagnose what exactly is causing this behavior.
This thread details how to find out the specific plugin, or the line in one's config, that causes such a behavior.
Alternatively, a delay in execution suggests that there is a mapping that interferes with it, as alluded by Ben in the comments. This can be investigated with :verbose imap <char>. (Note that imap <char> will list the mappings starting with <char>, and the use of :verbose will show where the mapping was created.)
Now, assuming the behavior is due to vimtex, :verbose imap # will return
i #B *@vimtex#imaps#wrap_math("#B", vimtex#imaps#style_math("mathbb"))
Last set from ~/.vim/plugged/vimtex/autoload/vimtex/imaps.vim line 119
i #- *@vimtex#imaps#wrap_math("#-", vimtex#imaps#style_math("overline"))
Last set from ~/.vim/plugged/vimtex/autoload/vimtex/imaps.vim line 119
i #c *@vimtex#imaps#wrap_math("#c", vimtex#imaps#style_math("mathcal"))
Last set from ~/.vim/plugged/vimtex/autoload/vimtex/imaps.vim line 119
i #f *@vimtex#imaps#wrap_math("#f", vimtex#imaps#style_math("mathfrak"))
Last set from ~/.vim/plugged/vimtex/autoload/vimtex/imaps.vim line 119
i #b *@vimtex#imaps#wrap_math("#b", vimtex#imaps#style_math("mathbf"))
Last set from ~/.vim/plugged/vimtex/autoload/vimtex/imaps.vim line 119
i #/ *@vimtex#imaps#wrap_math("#/", vimtex#imaps#style_math("slashed"))
Last set from ~/.vim/plugged/vimtex/autoload/vimtex/imaps.vim line 119
Hence, after # is pressed in insert mode, vim waits for a set time, as the next key may correspond to one of the maps listed above. (For example, the user may press # followed by b, which results in \mathbf{...}). This is why there is a delay after # is pressed (on its own), before # is actually inserted.
The output from :verbose imap also gives us a big clue how to resolve the issue. Searching within VimTeX's documentation :h vimtex for "imap", we see
INSERT MODE MAPPINGS *vimtex-imaps*
Some LaTeX commands are very common, and so it is both natural and convenient
to have insert mode mappings/abbreviations for them. VimTeX therefore
provides a list of such mappings that are enabled by default, see
|g:vimtex_imaps_list|
...
It is of course possible to customize the list of mappings. First, one may
specifically disable the entire imaps feature with |g:vimtex_imaps_enabled| or
specific default mappings through |g:vimtex_imaps_disabled|. ...
Thus, we can remove these mappings with
- either
let g:vimtex_imaps_enabled = 0, which disables all imaps set by vimtex,
- or
let g:vimtex_imaps_disabled = ['B','-','c','f','b','/'] which disables only specific imaps.
vim -u DEFAULTSloads without any plugins; then you can manually load ultisnips with the:runtimecommands. This sort of delay is commonly observed when there are mappings or abbreviations that start with the same prefix, so that's another place to investigate. – D. Ben Knoble Mar 30 '22 at 14:14let g:vimtex_enabled = 0. Refer to each plugin's help page – husB Mar 30 '22 at 14:16