Search code examples
vimvim-pluginlatex-suite

Vim with VOoM and LaTeX-Suite plugins result in odd key mapping behavior


I use latex-suite to write .tex files. To easily switch between default compiler (pdflatex) and xelatex I have the following script in my _vimrc file.

function SetXeLaTeX()
    let g:Tex_CompileRule_pdf = 'xelatex --interaction=nonstopmode -synctex=1 -src-specials $*'
endfunction
map <Leader>lx :<C-U>call SetXeLaTeX()<CR>

So in Vim, I can normally use \lx to call SetLaTeX() function. And actually I have similar scripts for other key-bindings such as \lp for pdflatex and \la for arara.

Everything works just fine until Voom outline command is called.

After runnig the command :Voom latex which generates Voom outline file .tex_VOOM1 alongside the .tex file, all these key mappings (\lx, \lp and \la) start behaving oddly:

They no longer calls my custom functions, instead they all trigger character-wise Visual mode.

It seems somehow Voom remapped all my commands. And I cannot over-ride it by running

:map <Leader>lx :<C-U>call SetXeLaTeX()<CR>

command in Vim's current session.

Can anybody tell me what is exactly wrong? How to fix this oddity?

Update

Strangely enough, I discovered that if I remove the <C-U> key in custom functions, no misbehavior is encountered. After this tweak, the \lx command will work as expected.


Solution

  • You should use :noremap; it makes the mapping immune to remapping and recursion.

    Apparently, Voom defines a <C-u> mapping, and your :map commands use that, and it's wreaking havoc on them.