Arduino code highlighting in Vim

Tue, May 26 2009
Posted by Jonathan Oxer A big thankyou to Johannes Hoff for putting together a Vim syntax highlighting file for Arduino development. Most people start their Arduino journey using the IDE but many then move on to using other tools, and for me personally my editor of choice has been Vim for so long I can't remember when I started with it. The Arduino language is really just C++ with some extra libraries thrown on top but because sketch files are stored with a .pde extension Vim doesn't even apply regular C++ highlighting by default, let alone highlight Arduino-specific functions. So Johannes put together an "arduino.vim" syntax file that you can grab from To get it running on my Ubuntu system these are the steps I followed: * Create the directory to store syntax files if it doesn't already exist: mkdir -p ~/.vim/syntax * Put the file you just downloaded into it: mv arduino.vim ~/.vim/syntax/ * Bind that syntax definition to files with the .pde extension by adding the following line to your ~/.vimrc file: au BufNewFile,BufRead *.pde setf arduino * Open a .pde file in Vim and type: :syntax on Voila! Syntax highlighty goodness for .pde files:
If you want Vim to always have syntax highlighting automatically each time you open a file, just add this to your ~/.vimrc file: syntax on Enjoy!