Sublime Text : Add space to your code

Read a code can be a pain, especially if you wrote it years ago or if someone else have to read it later. Fortunately, you are using Sublime Text !
So I recently learned to add space to my code; add some empty lines to separate blocks of related content and, more recently, between brackets.
Here is the solution to automatically add space between your brackets in Sublime text 2 or 3.

become

Here is how to tell to Sublime text to do that automatically

Open the user key binding file (Preferences -> Key Bindings – User) and copy this code :

Explanation

The interesting part is :

This is the result you want : [a space], the bracket, “$0” is where your cursor will be, then, the closing bracket.

Then, on line 10, you have to do the same for the case when your type a bracket to enroll your current selection :

After that, on line 16, we manage the suppression of the open-bracket, to remove the close-one.

You can do the same for all type of brackets : square “[” and curvy “{“.

Enjoy.

Links : Sublime Text

Published by

Constantin Guay

Currently Data Project Manager and Scrum Evangelist at NetMediaEurope, european leader in IT B2B news site (more than 12 million unique visitors per month). Passionate by user experience and data science. Scrum evangelist

Leave a Reply

Your email address will not be published. Required fields are marked *