I would like the :Toc command to call :Voom in R markdown files and :VimtexTocOpen in latex files.
First try:
au BufRead,BufNewFile *.Rmd command! Toc Voom
au BufRead,BufNewFile *.tex command! Toc VimtexTocOpen
It works as expected as long as I edit only one file type. If I edit first a markdown file in one buffer, then a latex file in another buffer. Then the :Toc command fails in the markdown buffer because it calls VimtexTocOpen.
Second try:
au FileType rmd command! Toc Voom
au FileType tex command! Toc VimtexTocOpen
It sets the :Toc command correctly in markdown files. Then sets it correctly in latex files. But when i go back to edit the markdown file, the command VimtexTocOpen is called and fails.
Third try:
au FileType rmd setlocal command! Toc Voom
au FileType tex setlocal command! Toc VimtexTocOpen
But this returns the error
Error detected while processing FileType Autocommands for "rmd":
E518: Unknown option: command!
E518: Unknown option: command!
Press ENTER or type command to continue
augroupis quicker to set up on a new machine because you can put it in the.vimrc. Unless I miss something about transferring a vim configuration including~/.vim/after/ftplugin/to another machine. Granted, Latex files are generally not the kind of file you edit on a server. – Paul Rougieux Jun 25 '20 at 07:18git cloneandsource set-dotfiles.shand I'm good to go, it's not longer because I have split my configuration. But yes it depends how you do it. – statox Jun 25 '20 at 07:22