1

I'd like to change filetype in autocmd FileType hook. Thre reason is that I'd like to use NeoMutt syntax file for .muttrc instead of Vim's default syntax file. I've installed NeoMutt's syntax files with Plug manager:

Plug 'neomutt/neomutt.vim'

And I've it in runtime path (I can set it with set ft=neomuttrc). But when I open ~/.muttrc, Vim still uses default syntax file (set ft? prints muttrc). I've tried the following:

autocmd FileType muttrc setl filetype=neomuttrc<CR>

but the filetype is still set to muttrc after I open ~/.muttrc. How can I change the filetype in autocmd FileType hook?

2 Answers2

2

<CR> should be removed:

autocmd FileType muttrc setl filetype=neomuttrc
leaf
  • 1,624
  • 11
  • 16
1

I tested it and this worked for me:

autocmd FileType muttrc set filetype=neomuttrc

I would recommend wrapping this up in a augroup and clearing the group.

augroup neomuttrc
    autocmd!
    autocmd FileType muttrc set filetype=neomuttrc
augroup END
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101