ele
ele

Reputation: 6181

How do I tell MacVim to always use a certain syntax highlighting with a certain file type?

I'm looking for something to add to my .vimrc that would tell MacVim to always use Markdown syntax highlighting with TXT files.

Currently, I can do this manually with set filetype=markdown but I have to do that every time I open a file.

Upvotes: 5

Views: 1699

Answers (1)

pb2q
pb2q

Reputation: 59607

You can automatically set the filetype for particular file extensions using autocmd:

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

Add this line to your .vimrc.

Type :help autocmd within vim for more details; see also: :help autocmd-group. See also: :help filetype.

Upvotes: 6

Related Questions