Quantcast
Channel: Korrelate Engineering Blog » Billy Watson
Viewing all articles
Browse latest Browse all 7

Adding Textmate Shortcuts to Sublime

$
0
0

I love Sublime Text 2  more than I love TextMate 2 and I think a lot of the Ruby community is heading down that road. However, I miss a lot of my TextMate shortcuts and, until now, I had no clue how to bring them into life in Sublime. A lot of the blog posts online aren’t very clear at detailing all that you can do.

Being a rubyist, when writing a hash in Ruby <= 1.8 form, the sequence => is used a lot and a little TextMate shortcut ctrl+l comes in handy. So to make this shortcut and only make in Ruby contexts, it’s actually really simple. Insert the following into user key bindings file (found in the menu at Sublime Text 2 -> Preferences -> Key Bindings – User). This file is in JSON format.

[   
  { "keys": ["ctrl+l"], "command": "insert_snippet", "args": {"contents": " => "}, "context":  
    [
      { "key": "selector", "operator": "equal", "operand": "source.ruby" }
    ]
  }
]

Using this example, you can add all of your favorite Ruby, HTML, Python, etc. shortcuts to SublimeText 2.

Sources:
http://www.sublimetext.com/docs/key-bindings
http://www.sublimetext.com/docs/contexts
http://sublimetext.userecho.com/topic/21146-key-binding-context-to-only-react-on-eg-python-code/


Viewing all articles
Browse latest Browse all 7

Trending Articles