Unlimited WordPress themes, graphics, videos & courses! Unlimited asset downloads! From $16.50/m
by
FREELessons:34Length:2.5 hours

Next lesson playing in 5 seconds

Cancel
  • Overview
  • Transcript

2.7 Key Bindings

Ironically, one of the things that Sublime Text is most often criticized for is what I love so much about it! Configuration in Sublime takes the shape of a JavaScript object. This means that practically anything and everything can be modified.

2.7 Key Bindings

One of my favorite aspects of Sublime Text 2 is how just about everything can be modified to your preferences. I'll give you an example. If I go to, Sublime > Preferences > Key Bindings- Default. Every single keyboard shortcut is going to be defined in this file and this means you have complete control over it. No longer do you have to go on Google and search for how to modify a particular shortcut. You can do it all from this file in five seconds. So let's try one out for ourselves. By default, to toggle the sidebar, I press Cmd+K and then B, Cmd+K, B and now we have toggled the sidebar. If I do it again, as you'd expect, now the sidebar is gone. Now that's fine for me, but maybe you don't like that sequence and you'd rather change it to something a little more memorable. Maybe something like, Ctrl+S, if you're on the Mac, and if you're on Windows maybe something different, because that wouldn't be the best choice. The only thing you need to keep in mind is the key sequence that you assign, make sure that it's not already assigned to a different effect and many times that will just take a little bit of guess and check. So if I want to change the side bar effect, the easiest way is to look for the side bar. So I would hit Cmd+I to do incremental search and I'll type side bar and there we are. Right here on line 17. So now we see the command is called toggle_side_bar and the assigned shortcut is super, which translates to Cmd on the Mac. Super is a key that comes from Linux. So if we were to change this and for now I'm going to copy it, just so we have a backup. Now I'm going to change it to Ctrl+S. So now immediately after I save the file, if I hit Ctrl+S, I'm now toggling the side bar and maybe that's better for you. Now there's one problem though, and I'm going to reference this a few times in the course. Never edit the default files, and the reason is when the next version of Sublime Text 2 comes out, your modifications are going to be overwritten and that's specifically why you're provided with the Key Bindings User. The user file is where you'll make all of your customizations. So with that in mind, I'm gonna copy this and uncomment the one that comes before it and save it. Now we will go to Sublime > Preferences > User and within here, I can paste in my object with my key binding. Now in this case, there is only one object. So I need to remove the comma from the end. So now that's done. Once again, Ctrl+S to toggle at the side bar and when Sublime is updated, that will still work rather than being overwritten.

Back to the top