remy
remy

Reputation: 1305

Vim: run some command when editing specific file

I want my Vim to run some commands, such as setlocal spell spelllang=en_us when I edit a file with extension of en, e.g. abc.en. How can I implement this?

Upvotes: 6

Views: 408

Answers (1)

perreal
perreal

Reputation: 97918

    augroup spell_settings
        au!
" set en_us as default language (unknown extension):
        au BufEnter * setlocal spell spelllang=en_us
" set en_us for en files specifically:
        au BufEnter *.en  setlocal spell spelllang=en_us
" to add multiple commands just append:
        au BufEnter *.en  setlocal syntax on
    augroup END

Upvotes: 7

Related Questions