9

In TextMate v1, there was an option to save on lost focus. That is, when you'd switch to another application, your TextMate documents would save. How can I recreate this behavior in TextMate 2?

Rose Perrone
  • 61,572
  • 58
  • 208
  • 243

5 Answers5

15

The way to do this has changed as of alpha.9495. From the README at the Save-On-Focus-Lost repo:

You can now set saveOnBlur in .tm_properties to make TextMate save files when focus is lost.
...

Using .tm_properties also allows to easily target specific file types, for example one could use:

[ ui/**.php ]
saveOnBlur = true

This would then only have .php files in the ui folder auto-save when focus is lost.

This is also really nice because it makes it possible to set this as a project-specific setting.

But if you want to set it as a global setting, edit the file ~/Library/Application Support/TextMate/Global.tmProperties and add the line saveOnBlur = True near the beginning, before any lines with filetype-specific settings.

Community
  • 1
  • 1
kmacinnis
  • 608
  • 5
  • 8
  • I can't get this to to work. I added `saveOnBlur = true` to the top of `~/.tm_properties`, restarted TextMate (even though it appears to watch for changes to that file) and when I switch to another tab or window, the file still isn't saved. Other changes I make to `.tm_properties` work fine, and I triple-checked my TextMate version as 2.0-alpha.9547. Any ideas? – Bungle Jun 11 '14 at 15:13
  • Try making the changes in the file `~/Library/Application Support/TextMate/Global.tmProperties` instead of `~/.tm_properties`. – kmacinnis Jun 11 '14 at 19:06
  • Hmm, that didn't work either. I also tried it in `~/.tm_properties` beneath a filename pattern (as shown in the example you cited), but no luck. – Bungle Jun 12 '14 at 01:26
  • This answer doesn't seem to still be valid for TextMate 2.0.23 on macOS Monterey – Jono Feb 10 '23 at 10:52
6

Edit the file: ~/Library/Application Support/TextMate/Global.tmProperties

and add the line:

saveOnBlur = true

The Global.tmProperties file is only loaded on startup so you need to save all changes, exit and re-run TextMate for this to take effect.

fuzzygroup
  • 1,109
  • 12
  • 12
4

There is a plugin for TextMate 2 that allow you to save on focus lost : Save-On-Focus-Lost, just install the plugin and you will have the feature back even in TexMate 2.

aleroot
  • 71,077
  • 30
  • 176
  • 213
1

The plugin: https://github.com/bomberstudios/Save-On-Focus-Lost.tmbundle works for me in mavericks but the path to the bundles is different than the one outlined in the instructions on github.

I think bundles are installed in: /Library/Application Support/Avian/Bundles in TextMate2

Cloning there the bundle (git clone https://github.com/bomberstudios/Save-On-Focus-Lost.tmbundle.git) worked fine.

nurieta
  • 1,615
  • 15
  • 6
0

The saveOnBlur setting only works for a file that has been saved at least once. That is, a file that exists on disk. If you test it by opening a new temporary file, typing something then switching away and back again, the file will not be saved because there is no file on disk. Save the temporary file then test. It should work.

simonb
  • 1
  • 2