One of the major pet-peeves of Arduino IDE is the inability to capture file/line of the compilation error and then get to that location with click. This feature is standard in IDEs in this century. I am going to show you how to setup external editor for compiling Arduino project and capturing compilation output.
Will use the ability of Arduino IDE to be invoked from command line and perform rebuild (they call it verify) and upload: Arduino/manpage.adoc at master · arduino/Arduino · GitHub
If you read instructions in manpage above carefully, you know that on Windows you have to call arduino_debug.exe instead of arduino.exe. Also I like that we can change build directory, so generated hex files can be added to version control. In the commands below I am configuring output to sketch subdirectory output by --pref build.path=$(FileDir)/output
You need text editor that is customizable. My favorite editor is SciTE: http://www.scintilla.org/SciTEDownload.html , On Windows I always use the installer with extensions as it integrates into Windows Explorer. The settings of this editor is in key=value format
Go to menu Options → Open User Options and add at the end:
file.patterns.ino=*.ino filter.ino=Arduino (ino)|$(file.patterns.ino)| lexer.$(file.patterns.ino)=cpp command.compile.*.ino="c:\Program Files (x86)\Arduino\arduino_debug.exe" --verify --board arduino:avr:nano:cpu=atmega328 --pref "build.path=$(FileDir)/output" "$(FilePath)" command.build.*.ino="c:\Program Files (x86)\Arduino\arduino_debug.exe" --verify --board arduino:avr:nano:cpu=atmega328 --pref "build.path=$(FileDir)/output" "$(FilePath)" command.go.*.ino="c:\Program Files (x86)\Arduino\arduino_debug.exe" --upload --board arduino:avr:nano:cpu=atmega328 --pref "build.path=$(FileDir)/output" "$(FilePath)"
You can override any options seen in Global Options. I also like to set:
line.margin.width=5 split.vertical=0 output.vertical.size=160 statusbar.visible=1 tabsize=4 indent.size=4 use.tabs=0 font.base=font:DejaVu Sans Mono,size:10 font.comment=font:DejaVu Sans Mono,size:10 font.text=font:DejaVu Sans Mono,size:10 font.embedded.base=font:DejaVu Sans Mono,size:10 font.embedded.comment=font:DejaVu Sans Mono,size:10 font.monospace=font:DejaVu Sans Mono,size:10
Save and restart SciTE to reload new settings. Now when you open Arduino sketch in SciTE, it will be syntax highligted and Tools → Compile and Tools → Build are now available and will invoke Arduino rebuild and all standard output is captured in output pane and SciTE is smart enough to understand them and click gets you to source file.
Tools → Go will upload to the target.
If you need to use different board than board you setup in cpp.properties, then create SciTE.properties in sketch directory and copy last 3 lines starting with “command.” and modify to your needs. Now next time you open the sketch in this directory, these local settings will override default ones. Another nice thing about local properties is that you can edit it by Options → Open Local Options and unlike global options this one gets reloaded before Tools → Build.