2

I am totally new to using Vim, and I have been trying out SpaceVim so far. One issue is with keybindings. So I have the Vimtex and Vim-Latex plugins installed. I want to use the compilation option from Vimtex because it automatically uses the latexmk program to compile my latex code. But, right now the Vim-Latex keybindings is mapped to the <Leader>ll keybinding.

I added the following command to the bottom of my init.vim file, as suggested in a different stackexchange post:

How can I redefine plugin key mappings?

Here is the command I used.

 autocmd VimEnter * noremap \ll VimtexCompile

But for some reason this does not change the keybinding. I am still getting the old keybindings.

I think that this keybinding is attached to the Latex mode in vim, since this keybinding will only work when it is in a latex file window. Unfortunately each time I currently press the \ll key, I get thrown into the compiler error log.

Any suggestions?

4
  • You probably really do not want to have both vimtex and vim-latex installed at the same time. Look at g:spacevim_disabled_plugins
    – Mass
    Sep 8, 2017 at 20:41
  • Oh interesting. So I did not really want to install both, but I have not been able to get vim-latex to work with latexmk. I have been trying for two days. So finally vimtex seemed to fix that. I did not want to lose all of the slick keybindings from vim-latex though. Is there a fundamental incompatibility between packages? I might need to keep this while I try and resolve the vim-latex issues.
    – krishnab
    Sep 8, 2017 at 20:50
  • @Mass Oh yes, I also did not get what you meant by the spacevim_disabled_plugins. I have a custom plugin section in my .init.vim file, but not a section for disabled plugins. Is one of the latex plugins on the disabled plugins list?
    – krishnab
    Sep 8, 2017 at 20:52
  • sorry, I misunderstood the question and mistakenly assumed vim-latex was included with spacevim. The basic problem you are encountering is that file-type specific plugins generally make <buffer> maps which override your global map. Something in spacevim must be overriding it. \ll is the default compile map for vimtex, so you must have a conflict somewhere.
    – Mass
    Sep 8, 2017 at 21:20

1 Answer 1

3

Disclaimer: I'm the author of vimtex.


You should not use both vimtex and vim-latex at the same time. They are filetype plugins that try to implement the same set of features, at least partially. For some more information about the difference between the plugins, you can read some of the answers here: What are the differences between LaTeX plugins?

That said, it is possible to use both plugins at the same time. You could disable the vimtex mappings with the option g:vimtex_mappings_enabled. Then, you could map your desired keys to the specific commands that you want. I prefer to do such things in my own custom ftplugin/tex.vim files (or similar for other filetypes), but you can also use an autocmd such as:

autocmd FileType tex nnoremap <leader>ll :VimtexCompile<cr>

To sum up: I recommend that you use either vimtex or vim-latex, not both. If you invest some time, I think you will find that vimtex should provide all or most of the useful features from vim-latex, as well as a lot of other useful features. Further, some or most of the other features are left out because other more dedicated plugins should be used instead. As an example, you should look into Ultisnips or neosnippet for insert mode mappings that trigger "templates". See :h vimtex-non-features (the link points to the master version of the docs, and so the line number may change in the future).

3
  • Ah thanks for the answer. Yeah, I would like to use vimtex and read over the sections you mentioned in the helpfile. So I can use UltiSnips, but do I have to recreate all of the shortcuts from vim-latex again? I was trying to see if anyone had already done this. I am googling around looking if anyone has done this. Is there a mention of anyone having done this in any of the issues on github?
    – krishnab
    Sep 8, 2017 at 21:30
  • There are also some shortcuts in vimtex, see :h vimtex-imaps. Perhaps this is part of what you're after? Sep 9, 2017 at 7:47
  • The list of shortcuts is not added to the docs, because there are many. To see the list, open the autoload/vimtex.vim file in the vimtex repository and search for g:vimtex_imap_list. Sep 9, 2017 at 7:49

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.