Rafael Bugajewski home

Fix TextExpander in MacVim

Sunday, 29 May 2011

2015-05-24 Update: I was contacted by the awesome folks at Smile Software. The workaround described in this article no longer applies for TextExpander 4.x and newer:

Unfortunately TextExpander expects that key to hold an array value, not a string value as you suggest. Making the described change makes the Settings.textexpander file unreadable by the application. The correct instruction would be to insert



Of course, that only makes a difference with TextExpander from the 3.x vintage, and on OS X prior to 10.7, so overall the instructions really aren’t applicable at all for TextExpander 4.x and current OS X’s.

TextExpander is the tool you need to install on your Mac. It works flawlessly in the background and substitutes all of your abbreviations with meaningful snippets. Newer versions of TextExpander support smart replacement which basically means that they don’t use the clipboard anymore. Instead they detect that you work inside a Cocoa text view and try to replace the abbreviations in a smarter and much faster way. Unfortunately MacVim uses its own implementation of Cocoa’s text view which misses some functionality. TextExpander doesn’t detect this and inserts strange characters into MacVim.

One workaround is to activate „Always use clipboard to insert snippet“ in the „Expansion“ tab of TextExpander’s preferences. This has the huge drawback that replacing abbreviations works slower than it should—everywhere on your Mac.

Fortunately Smile’s support ninjas mailed me a solution within a couple of hours. In three easy steps you can get the best of both worlds: the old clipboard replacement in MacVim and the new and blazingly fast replacement method in other applications without manually changing preferences.

  1. Quit TextExpander.
  2. Open /Users/rafael/Library/Application Support/TextExpander/Settings.textexpander (preferably with Xcode 4 or the Property List Editor).
  3. Add the key forcePasteBundleIDs with the string value org.vim.MacVim to the property list and save it; don’t forget to restart TextExpander.

That’s really everything you need to do to enjoy your TextExpander snippets in MacVim without having to use the old replacement functionality.