2

Here is a sample of my .vimrc, that doesn't do a thing (the autocmd does not work) when I open a .md or .tex file, but works fine for .py files:

augroup filetype_python
  autocmd FileType python nnoremap <buffer> <localleader>c I#<esc>
  autocmd FileType python set nu
  autocmd FileType python :iabbrev <buffer> iff if:<left>
  autocmd FileType python :iabbrev <buffer> forr for:<left>
  autocmd FileType python :iabbrev <buffer> while while:<left>
  autocmd BufWritePre,BufRead *.py :normal gg=G
augroup END

augroup filetype_tex
  autocmd FileType tex set nu
augroup END

augroup filetype_markdown
  autocmd FileType markdown onoremap i= :<c-u>execute "normal! ?^==\\+$\r:nohlsearch\rkvg_"<cr>
  autocmd FileType markdown onoremap i- :<c-u>execute "normal! ?^--\\+$\r:nohlsearch\rkvg_"<cr>
augroup END

As if Vim didn't know about markdown and tex (but it's supposed to, I checked the list of all known FileTypes and they were there)... Any ideas ?

Thanks in advance !

  • Vim doesn’t treat .md flies as markdown by default. Either rename your files to have .markdown extensions, or tell Vim to treat .md files as Markdown. – Rich Jul 10 '18 at 22:36
  • See also :help new-filetype – Rich Jul 10 '18 at 23:03
  • Related: my answers about autocmd and filetypes one two – D. Ben Knoble Jul 10 '18 at 23:53
  • Actually, it seems that the problem only needed my computer to sleep one night to solve itself on its own. But thank you anyway! – Ul Tome Jul 11 '18 at 19:45
  • 1
    Oh and maybe adding:let g:tex_flavor="latex" – Ul Tome Jul 11 '18 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.