Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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 Sakhnov Jul 26 '11 at 11:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.