How to tell MacVim to always use syntax highlighting with a specific file type?

I am looking for something to add to my .vimrc that tells MacVim to always use Markdown syntax highlighting with TXT files.

Currently, I can do it manually using set filetype=markdown, but I have to do it every time I open the file.

+5
source share
1 answer

You can automatically set the file type for certain file extensions using autocmd:

autocmd BufRead,BufNewFile  *.txt,*.TXT set filetype=markdown

Add this line to yours .vimrc.

Enter :help autocmdinside vim for more details; see also.: :help autocmd-group. . See also: :help filetype.

+5
source

All Articles