noli
noli

Reputation: 16006

How can I set a VIM filetype programmatically?

Is there a way to set a vim filetype programmatically, so instead of doing something like this:

au BufNewFile,BufRead *.dump set filetype=sql

I can do something like this

let g:temp_file_type = 'sql'
au BufNewFile,BufRead *.dump set filetype= g:temp_file_type

Upvotes: 3

Views: 591

Answers (2)

nate c
nate c

Reputation: 9005

put au BufNewFile,BufRead *.dump set filetype=sql into your filetype.vim

Upvotes: 1

Laurence Gonsalves
Laurence Gonsalves

Reputation: 143314

You can set options with let by prefixing the option name with &. eg:

let &filetype=g:temp_file_type

Upvotes: 6

Related Questions