Wednesday, September 03, 2008

SciTE tweaks

My favourite text editor for Windows and Linux is SciTE. Generally speaking, it does everything the way that I like it done, and is fairly lightweight to start up. For most of the heavy-lift editing I do, I'll use Eclipse. So SciTE is just for tasks where it's not worth starting up Eclipse, or the file I want to edit is not in a project. While SciTE is fairly customisable, most of the defaults are the way I like it. There are a few things, though, that I always have to set when I switch machines, do an OS upgrade, etc. Here are my top SciTE tweaks, all of which are simply written into the SciTE user properties file. Happily, SciTE itself has an 'edit the user properties' menu action, and, even better, re-parses that file each time you save. So no need to exit and restart.

Monospace font

If I'm text editing, it has to be a fixed width font or nothing. SciTE doesn't have a Boolean 'use monospace' flag, but it's not much harder than that: choose a nice monospace font, and then ensure that gets used uniformly.

if PLAT_GTK
 font.monospace=font:!Inconsolata,size:10
if PLAT_WIN
 font.monospace=font:Inconsolata,size:10

font.base=$(font.monospace)
font.small=$(font.monospace)
font.comment=$(font.monospace)
font.text=f$(font.monospace)
font.text.comment=$(font.monospace)
font.embedded.base=$(font.monospace)
font.embedded.comment=$(font.monospace)
font.vbs=$(font.monospace)

Inconsolata, incidentally, is a really nice programming font, and is mercifully consistent between Gnome and Windows XP. Thanks Jeff Atwood for the initial suggestion there.

New edit buffers in text mode

SciTE is syntax-sensitive, which is nice. When I create a new, empty buffer I'd like the language to be text - which basically does nothing at all. By default, a new buffer comes up in C mode, which probably suits some people but not me. The language mode is set by the extension of the file being edited, so to get default text mode we set the default extension:

default.file.ext=.txt

See all files in the file open dialogue

SciTE can filter the contents of a directory, so that you only see matching files in the file open dialogue. Nice enough, but by default it filters on 'all source', which selects a broad church of .c, .java, .perl, etc etc files, but not broad enough for my taste. I'd like to have the default filter be everything, then can choose other filters if I need them (and I hardly ever do).

if PLAT_WIN
 all.files=All Files (*.*)|*.*|
if PLAT_GTK
 all.files=All Files (*)|*|Hidden Files (.*)|.*|

open.filter=\
$(all.files)\
#All Source|$(source.files)|\
$(filter.conf)\
$(filter.bash)\
$(filter.caml)\
$(filter.caml)\
$(filter.cmake)\
$(filter.cpp)\
$(filter.css)\
$(filter.eiffel)\
$(filter.erlang)\
$(filter.java)\
$(filter.js)\
$(filter.lua)\
$(filter.matlab)\
$(filter.perl)\
$(filter.php)\
$(filter.properties)\
$(filter.ps)\
$(filter.python)\
$(filter.ruby)\
$(filter.sql)\
$(filter.tcl)\
$(filter.tex)\
$(filter.text)\
$(filter.vb)\
$(filter.web)\
$(filter.yaml)

I copied this setting from the global properties file, then edited it down to just the filters I (think that I might) make use of. I also switch all.files to be at the top of the list, which makes it the default. The all.source is commented out as it seems to slow the file open dialogue down on my Linux box.

Tabs? No thanks

I long ago learned to eschew tab characters in source code. Good code is laid out neatly. People have all sorts of weird settings for the size-in-spaces of a tab character, with the result that tab-aligned lines look like crud most of the time.

tabsize=4
indent.size=4
use.tabs=0
tab.indents=1
backspace.unindents=1