FolderSpecificSettings

Many settings can be specified per folder and even per file type, here are the default values:

exclude = "{*.{o,pyc},Icon\r,CVS,_darcs,_MTN,\{arch\},blib,*~.nib}"
include = "{.tm_properties,.htaccess}"

TM_HG  = "/opt/local/bin/hg"
TM_GIT = "/opt/local/bin/git"

[ "/usr/include/{**/,}*" ]
tabSize = 8

[ *.{txt,md,mdown,markdown} ]
softWrap = true

[ .git/COMMIT_EDITMSG ]
softWrap         = true
spellChecking    = true
spellingLanguage = 'en'

[ *.{icns,ico,jpg,jpeg,m4v,nib,pdf,png,psd,pyc,rtf,tif,tiff,xib} ]
binary           = true

[ source.ruby ]
softTabs         = true
tabSize          = 2

[ "/System/Library/Frameworks/**/Headers/**/*" ]
encoding         = "MACROMAN"

[ "{README,INSTALL,LICENSE,TODO}" ]
fileType         = "text.plain"

Load Order

It will read from current folder and up until either it reaches ~ or /. If it reaches / then it will additionally read ~/.tm_properties. This means you can have “global” settings in that file and they work even when opening stuff not under your home folder.

In the file you can do sections with a glob against full path to restrict the following settings to just those which match the glob.

In the variable part you have a few variables, the usual $TM_FILEPATH and friends, but you also have $CWD, this is the folder containing the property file. This is useful if you put a .tm_properties file in the root of your project, for example I use this file with Avian:

# Settings
tabSize              = 3
projectDirectory     = "$CWD"
windowTitle          = "$TM_DISPLAYNAME — ${CWD/^.*\///}"
excludeInFileChooser = "{$exclude,*.xib}"

# Variables
TM_ORGANIZATION_NAME = 'MacroMates'

TM_SYS_HEADER_PATH   = '${TM_SYS_HEADER_PATH:?$TM_SYS_HEADER_PATH:/usr/include/c++/4.0.0:/usr/include:/System/Library/Frameworks}:$CWD/Shared/include:${BUILD_DIR:-$CWD/build}/Avian/public'
TM_TODO_IGNORE       = '/(disabled(-src)?|onig-.*|build|cache|CxxTest|(FScript|BWToolkitFramework).framework)/'

TM_MAKE_FILE         = '${CWD}/Makefile'
TM_MAKE_TARGET       = 'Avian/run'

[ target ]
fileType         = "source.tm-properties"

[ *.{h,pch} ]
fileType         = "source.objc++"

[ Makefile.* ]
fileType         = "source.makefile"

[ attr.untitled ]
fileType         = 'source.c++'

[ "tests/*.{cc,mm}" ]
scopeAttributes  = 'attr.test.cxxtest'
TM_MAKE_TARGET   = '${TM_FILEPATH/^.*?([^\/]*)\/tests\/.*$/$1/}/test'

[ "rmate/*" ]
TM_MAKE_TARGET   = rate

[ vendor/MASPreferences/**/*.{m,h} ]
tabSize      = 4
softTabs     = true
TM_C_POINTER = " *"

As you can see I set the Makefile via CWD — here I can’t use TM_FILEPATH or similar, because those will be the “current file”, not the project root.

Some things of interest is how e.g. test files get the scope augmented, this is because I have unit test snippets I only want active in test files. Additionally I change the make target for test files.

While the .tm_properties can contain both settings and environment variables, while interpreting the file, Avian doesn’t distingish between the two, so it is possible to mix them in the value part and also reference already set variables, e.g. if we want to extend the default exclude setting we can do:

exclude = '{$exclude,*.o}'

The value is a glob so we use brace expansion to add the *.o extension.