Search code examples
vimvi

Open cir sp sim with spice syntax


Problem statement: When I open a file with .sp extention with vim it opens with spice syntax which the same file with .sim/.cir extension does not open with spice syntax.

My efforts: I tried by added the below line in .vimrc but it's not working.

au BufRead *.sim setfiletype spice

Details: I have the following lines in .vimrc

syntax on

filetype on

Looking for: I am looking for an option that we can add in .vimrc to enable a set of file extensions(sim/cir/sp) to open with a spice syntax.

Thanks.


Solution

  • If it doesn't already exist, create the following directory:

    ~/.vim/ftdetect
    

    Then create ~/.vim/ftdetect/spice.vim (the filename doesn't have to be spice.vim) with the following content:

    autocmd BufNewFile,BufRead *.sim,*.cir set filetype=spice
    

    See :help new-filetype.