After installing Sublime Text 2 these are the settings I use and packages I install to assist with Ruby on Rails development. Use all or some of these to suit your own needs.
Remove the Minimap
View > Hide MinimapInstall Package Manager
View > Show consoleCopy code below / paste / enter
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
Install Ruby / Rails related Packages
Preferences > Package Control > Package Control:Install Package- ERB Insert and Toggle Commands
- Rails Related Files
- RubyTest
- Rspec
- Guard
- Haml
- Sass
- Coffeescript
User Settings
Preferences > Settings - UserCopy code below / paste / save
{ "color_scheme": "Packages/Color Scheme - Default/railscasts.tmTheme", "font_face": "Droid Sans Mono", "font_size": 12, "scroll_past_end": false, "detect_indentation": false, "tab_size": 2, "translate_tabs_to_spaces": true, "trim_trailing_white_space_on_save": true, "word_wrap": true }
Create a plugin to Open file in browser
Tools > New plugin...Copy code below / paste / save as OpenBrowser.py
# OpenBrowser.py import sublime, sublime_plugin import webbrowser class OpenBrowserCommand(sublime_plugin.TextCommand): def run(self,edit): url = self.view.file_name() webbrowser.open_new(url)
Add Keybindings to Open file in new browser and to insert ERB
Tools > Command Palette > "User Key bindings"Copy code below / paste / save
[ { "keys": ["ctrl+shift+b"], "command": "open_browser" }, { "keys": ["ctrl+shift+."], "command": "erb" } ]
Hey, thanks for taking the time to write this post (and the rest of your blog)!
ReplyDeleteI've taken some time over the bank holiday to dive into RoR and have been following along with http://ruby.railstutorial.org/ which is so far, so good. Your install guide and Postgre sql post has already helped me get up and running quickly!
There's just one thing... I've been able to setup my sublime text to do everything except run the rspec tests. I've installed the RubyTest Sublime plugin, but cant seem to get the rspec tests to run in sublime even though they're working through the command line. Was wondering if it would be possible to share your testing setup in sublime? Cheers in advance!
Managed to get it sorted: I've got my sublime installed in $USER/bin/sublime2
ReplyDeleteI made a subl executable in $USER/bin with $>ln -s $USER/bin/sublime2/sublime_text subl and just ran 'subl .' from the command line to launch the editor which seems to be working well
Cheers,
Huntly
Hi Huntly,
ReplyDeleteThanks for your comments and i'm pleased you are finding this blog useful.
Running RSpec tests from S2 is more tricky than it should be, congratulations on finding a solution and including it in your comment. I'm sure others will find it useful.
Cheers!
Ben
Hi, thank you for your post,
ReplyDeleteI have an issue, when using openbrowser pluging, file is open in TextEditor not in browser.
Regards.
Hi Daniel,
ReplyDeleteI've not encountered this issue, but there is a similar issue here in the Sublime forum:
http://www.sublimetext.com/forum/viewtopic.php?f=3&t=10595
Or for an alternative take a look at this project: https://github.com/adampresley/sublime-view-in-browser