Switching to Sublime Text 2
Updated – 07/16/2012
Please see my updated post for current instructions on getting Sublime Text 2 up and running on your machine.
Updated – 01/12/2012
I recently switched over to Sublime Text 2 for my primary development editor. I was waiting to see what TextMate 2 would be like, needless to say I didn't see much an improvement. Sublime Text 2 has got some nifty features like multiple columns, rows, or even grid views. After a few hours of having 2 files open side by side I was hooked. Below are the things I had to do to get it customized enough for me to use every day. As I continue to customize and setup Sublime Text 2 I'll be updating this post.
Command line Tool
To be able to open a file or folder from the command line from anywhere create a symlink to the subl command line tool.RVM
Edit Sublime Text's ruby settings file:It should look like this:
"cmd": ["ruby", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby"
}
Change it to this (replacing nickd with your username) in order to use the rvm-auto-ruby binary:
"cmd": ["/Users/nickd/.rvm/bin/rvm-auto-ruby", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby"
}
Spacing and tabs
You can set Sublime Text 2 to use spaces instead of tabs and adjust the indentation, however it seems to only change it for the current file your on, to make it global edit the User Base File settings file. Update – As Kevin Yank & Dimitar Dimitrov point out in the comments, it is best to put any custom user settings in the User packages. This way updates won't overwrite them."tab_size": 2,
// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": true,
RSpec & Test::Unit
I found this great plugin for running both RSpec and Test::Unit tests from within Sublime Text 2, https://github.com/maltize/sublime-text-2-ruby-tests. It allows you to run all the tests in an individual file and also supports focused tests, however focused tests don't seem to work for me. To get this installed:Sublime Package Control
Update – I'd like to thank Dimitar Dimitrov & Pablo Barrios for pointing out Will Bond's Package Control. Sublime Package Control is a great addition to Sublime's ecosystem. There are ton of useful packages and themes that you can add just by selecting them. Just follow the simple installation instructions and you'll be good to go.Press cmd + shift + p and type "Package Control" to find all the options for this add on. You can also get to it under the Preferences Menu.
CoffeeScript
Sublime Text 2 supports TextMate bundles, to get CoffeeScript syntax highlighting just install the bundle through the package control.Haml & Sass
To get Haml & Sass support clone this repository and copy the Ruby Haml and SASS folders into the Packages folder.Comments
I've been using Sublime Text 2 for quite some time now and I'm very happy with it. This editor makes me happy and I feel very productive with it, which is important for me.
I've got a few tips about it:
What Kevin Yank said about the settings file; while you have a Ruby file opened, you can use the menu item under "Sublime Text 2" → "Preferences" → "File Settings - More" → "Syntax Specific - User" to open the config file for that specific syntax; it will be safe to edit there
Use some kind of package control, like this one
Inspecting the "Sublime Text 2" → "Preferences" → "Key Bindings - Default" file, one learns a lot about available shortcuts, how the editor works internally and even how to easily extend or tweak its functionality
In my opinion, Sublime Text 2 has great potential. I very much like the design concepts in it (multiple carets/selections, all that commands stuff, etc). It's still a bit under-documented and is missing a central place to collect knowledge about itself, but I consider that okay, given the fact it's still in beta. Also, I'm very fond of the transparent development process, in contrast with TextMate's development.
Nice post, but let me tell ya that all of this is much easier with Package Control http://www.sublimetext.com/forum/viewtopic.php?f=5&t=2746#p12731
There is even a Git package that it is really great. BTW, I think that Sublime Text 2 is the "emac/vim" of the XXII Century.
Best.
Great post, adding subl to the CLI was great and couldn't figure it out for the life of me!
My only question is how do you change themes after downloading them (for instance - "Soda Light/Dark")? It downloads to the package folder but it doesn't populate in the theme list.
Richard,
Glad I could help. I'm not really sure how to get the Soda theme working, I gave it a whirl and it didn't work for me either. Maybe you can post an issue with the developer https://github.com/buymeasoda/soda-theme
I'm currently using the Soda Dark theme. I think the instructions in its GitHub page are good. Do this:
- Install it by following the Installation instructions here
- Then apply the instructions from the Activating the theme section
I needed to restart Sublime Text 2 to make sure the theme is properly loaded, otherwise the GUI had some glitches. Other than that, it works like a charm.
I'm having a less than happy experience so far with my last 2 days using Sublime Text 2. I'm a long-time TextMate user like most people, and I've been spending a ton of time googling and installing packages to try to get me back to on-par of where I feel like I am with TM, and it's just not happening. I just finally got this working so I can run my specs, but it's just the ugly console view. Where's my awesome html output with clickable lines that I'm used to in TextMate? Also, installing the RSpec TM bundle is a 1-liner and poof it's working. This ST2 thing took me a good 10 minutes to get my ugly console output working and a bunch of steps copying over setting files across disjointed directories, copying and pasting changes in setting files, installing a package manager, installing packages. I keep reading articles about how ST is so awesome and I feel like I'm missing the punchline here. This is a complete mess compared to the TM experience. What do I have to do to feel like ST is better than TM? Sorry if I sound like a negative Nancy but I keep reading such amazing hype for ST and I'm just not understanding the appeal and switching has not been fun at all. I am honestly giving it a fair try though!
Great post. I am a noobie and not sure if I should be asking this here but I am trying to find this specific information on various forms but can only find fragments of tips and having a challenge to integrate all of them.
I am looking for the following:
- A simple (as automated as possible) way to set up test db and run rspec tests from sublime.
- When I run the test (one specific rspec file or all of them) it should do the following: a) drop test db b) create test db and do all migrations c) load seed data d) load test data (Factories) e) and finally run the selected tests
- All of the above should be done without leaving sublime
Pardon me, if this request does not make sense here. I know that it involves rake db tasks and installing rspec plugin and configuring it in sublime.
If someone has already done it, I would appreciate if you can describe the steps.
¿How can install RSpec on Sublime Text 2? I want to be able to run tests from Sublime Text 2 using "command + b" or something like it.
Thanks.
Alexandra,
It is already mentioned in the article. go here: https://github.com/maltize/sublime-text-2-ruby-tests
Excellent advice! One thing, though: you shouldn’t modify the Base File.sublime-settings file in the Default directory, as it will be overwritten when Sublime Text 2 is updated. Effectively, that file should always contain the “Factory Defaults” for the editor. Instead, you should override whatever settings you like in your own User settings file. See the Sublime Text 2 docs for details.