How do I make vim automatically apply c++ syntax highlight on Arduino files (.ino/.pde)?
How do I make vim automatically apply c++ syntax highlight on Arduino files (.ino/.pde)?
Or how does vim syntax highlight know what is a c++ file? And how can I tell him that files that is called .ino and .pde is also c++ files.
Add something like this to ~/.vimrc
:
autocmd BufNewFile,BufReadPost *.ino,*.pde set filetype=cpp
Or more correctly, to ~/.vim/ftdetect/cpp.vim
.
Vim searches for syntax files named {name}.vim
where name represents the language, for example cpp.vim
for c++ files. If you want that an .ino
file has his own syntax highlight create a file called ~/.vim/syntax/ino.vim
and you can start use it with :set syntax=ino
. In your case you can create a link to a cpp.vim
file.
ln -s /usr/share/vim/vimcurrent/syntax/cpp.vim ~/.vim/syntax/ino.vim
You can create an autocommand as follows:
au BufRead,BufNewFile *.pde,*.ino set filetype=c++
Put this into your .vimrc
to make the setting persistent.