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