Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I’m using TextMate 1.5.10 on OS X Lion, and for some weird reason I don‘t get autocomplete for single quotes ('). Double quotes (") work fine.

Since I personally prefer to use single quotes whenever I code in JavaScript or PHP, that thing annoys me a little. And as far I have googled, TextMate is actually supposed to autoclose single quotes by default.

So why doesn’t this work for me and how do I force-enable this feature?

share|improve this question
up vote 5 down vote accepted

Which pairs are auto-inserted depends on the actual language and the bundle that is loaded for it.

The actual character pairs are defined in the bundle preferences with different settings for different languages and contexts. For example, in source code an apostrophe is set up to have itself as a closing character, except for comments and strings. This is achieved using scope selectors.

For example, if you want to enable single quote autocompletion for Plain Text, you will have to edit the preferences of this bundle according to the TextMate manual.

Go to BundlesBundle EditorShow Bundle Editor. In the left pane, select "Text", and "Miscellaneous". Here, add the following line to smartTypingPairs (note that you have to enter the single quotes within double quotes):

( "'", "'" ),

enter image description here

Close the Bundle Editor, and it should work for every file recognized as Plain Text. If it doesn't work instantaneously, reload the bundles with BundlesBundle EditorReload Bundles.

To change it for other languages (like JavaScript or PHP), you will have to inspect the preferences of the corresponding bundles.

share|improve this answer
Obviously, if the preferences don't exist yet, you may create them using the + button. – slhck Jul 25 '11 at 12:02
I am also confident that I was able to auto-complete single-quotes before my update to Lion, but alas, upon reading the OP's question, I tried it and it didn't work. Then, in reading this, I was able to add ( "'", "'" ), to the first line of smartTypingPairs and it works perfectly again. Thanks, @slhck! – mkoistinen Jul 25 '11 at 12:32
Great, thank you. Indeed, just like @mkoistinen, for some weird reason I didn’t have that last line highlighted in the screenshot. Added it, and it works. – Arnold Jul 26 '11 at 11:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .