Why and how to Sublime?

Marcin Styszewski
DaftMobile Blog
Published in
7 min readMar 17, 2017

--

Did you know that you can write text in text editors? Pretty convenient, huh?

What is your weapon of choice when it comes to text editor? Oldschool vim or action packed IDE? In my opinion, SublimeText fits perfectly in the middle.

Disclaimer: All the shortcuts in the following article are Linux friendly and they might differ on macOS. Please keep that in mind. Most of the times the difference will be switching ctrl to cmd, however, if you will encounter any problems — feel free to write it down in the comments section and I’ll be happy to help.

Why Sublime?

  • It’s easy — you open it and it’s ready to use. Even though a number of options are countless Sublime’s entry level is very low. Comparing to advanced IDEs or simple (haha) vim, it might not instantly give you everything they do, but it will provide you with the basics and grow with your needs.
  • It’s fast — hell yeah it is! As a Ruby developer I tried JetBrains RubyMine. The romance was very brief as RM came, took all my RAM and left me brokenhearted. Atom was my another mistress, but the bigger the project was, the longer it took to open. It came to a point when I could make myself a cup of coffee while waiting for Atom to finish loading. All in all, I ended up coming back as prodigal son to Sublime.
  • It’s customizable — hundreds of themes? Checked. Want to write everything in Comic Sans? Feel free. Need brainfuck support? Checked. Color scheme not bright enough? Take another one with higher saturation — again — there are hundreds. We will get to that later, but the possibilities are endless.

So how to start?

Control your package

Plenty of features awaits you in packages. And what’s the first package you should get? Package Manager of course! Here you will find instructions on how to install it.

How does it work? After installation press ctrl + shift + p and start typing install — autocomplete will suggest Package Control — Install Package. Press enter and embrace over 1800 ready-to-go plugins.

* Apparently, there is also an option to install Package Manager directly from Sublime itself. Press ctrl + shift + p and choose Install Package Manager option. I did not test this solution, but it sounds convenient.

Make it fabulous!

Sublime supports installing themes through Package Control. My personal favorite is Material Theme. If you feel the need to customize it more (I know I did) go to Preferences -> Settings and go wild!

Material Theme in action.

Let it work for you

Some plugins that I’m using, I’d recommend for everyone to try them out. I’m aware that there are a lot of ’10 MUST HAVE PLUGINS FOR SUBLIME TEXT’ or ‘THINGS TO DO RIGHT AFTER INSTALLING SUBLIME TEXT ’ etc. articles. The following ones are the ones I ended up using and getting most of them as a Ruby developer.

Package Control

As mentioned before, it is first-to-go Sublime package. Install plugins from inside instead of importing packages and looking through files tree. Easy to use and self explanatory.

indentX

If you ever had to browse through long and complicated .json or .xml files you’re gonna love this plugin. As the name indicates it prettifies your files with intends and thus makes them more readable.

BracketHighlighter

This little fellow highlights where the bracket begins and ends. Small thing but very useful.

GitGutter

See Git diff inside your Sublime files. GitGutter marks all changes in files that are added to git repository. It comes with small indicators located in the gutter (hence the name) that shows you which lines were modified and how (something was added/deleted/changed).

SublimeLinter

As a ruby developer, I’m using both SublimeLinter-rubocop and SublimeLinter-ruby. Errors are showed both in the gutter and the footer section. Easy to set and very useful. It comes with a vast amount of languages support.

SideBarEnhancements

Gives you more options for Sublime files tree. Things like Rename/Move/Duplicate comes in handy. Another thing is opening files directly in browsers or application of your choice — pretty convenient huh?

AllAutocomplete

Best feature ever. Suggest auto completion as you’re writing from all currently open cards.

If that’s not enough you will surely find more favorite-package-lists out there.

Some Tips

Exclude directories

With great projects comes great responsibility. And files amount. And logs. And assets. And git. And tests. And cache. After a while, you might end up with a vast amount of files to index to search. Even though Sublime sure is fast but going through thousands of images and log lines would be exhausting for everyone. A simple solution for that problem is to exclude not relevant directories from indexing.

1. Open Preferences -> Settings.
2. Exclude directories you don’t need e.g.

“folder_exclude_patterns”: [“public”, “log”, “vendor/assets/*.jp*”]

3. Profit.

Multiple projects management

So you have lots of projects you are working on? Are you tired of switching them with several clicks? I feel you bro. Here is a solution for your problem.

Lol what? It took just one .gif to handle multiple projects? This is crazy!

1. Open project you want to be able to reach in a matter of seconds.
2. Save it as Sublime project by going to Project -> Save Project As…
3. Add more of your precious projects like that.
4. Use ctrl+shift+p to open currently saved project list.
5. Choose whichever you want to open and puff!
6. Profit.

Ruler

Some people like it, some people don’t. I’m not judging I’m just saying that if you feel the need to not exceed 80 characters per line and seem to forget it along the way — Sublime ruler rules!

1. Choose your ruler rules from View -> Ruler options and never again wonder is the line too long. Simply see it is.
2. Profit??

Set project rules

Working with several people? You prefer 2 tabs for intendetion and your colleagues 4 spaces? Some of you are leaving whitespaces after the line, some of you don’t? Sublime gives you simple settings for removing this kind of obstacles from your way to the perfect code:

1. Open Preferences -> Settings
2. Talk with your team and set up some ground rules e.g:

{
“trim_trailing_white_space_on_save”: true,
“ensure_newline_at_eof_on_save”: true,
“translate_tabs_to_spaces”: true,
“tab_size”: 4
}

3. Never talk about this things again and become a better man.
4. Profit.

Layout settings

Who likes to see every file he’s currently working on at the same time? Cause I’m guilty as charged! On when writing test I like to split screen to see exactly what class I’m testing. When doing HTML views it’s nice to have style sheets open as well. Sublime got you covered with multiple layout options. With alt+shift+1–9 You can easily switch different window layouts and choose the most convenient one for you.

If you will tap different numeric keys fast enough you can make Sublime looks like it’s broken. Give it a go!

Auto save

While working on multiple files sometimes the focus can be lost. Did I save it? Let me just save it another time, just to be sure. Instead of smashing hard that ctrl+s on multiple cards just take a look:

1. Open Preferences -> Settings
2. Set the following:

{
“save_on_focus_lost”: true
}

3. All your work will be saved every time you will leave Sublime, switch a card, switch project, you name it. It’s like you hardly have to do anything nowadays!
4. Profit!

Regex support

This might be your precious time, and therefore life, saver. Sublime’s Find and Replace has an out of the box regex support for all your searches.

Useful Shortcuts:

Did you know that you can assign left_delete to enter? Give it a try and surprise your friends and family!

ctrl+d — select first duplicate of current selection and appends cursor.
ctrl+shift+p — opens list of current installed plugins functions
ctrl+h — find and replace in current file
ctrl+shift+f — find throughout the directory.
ctrl+p — go to file
ctrl+shift+k — remove current line
ctrl+} — move selection one tab(or space) to the right
ctrl+{ — move selection one tab(or space) to the left
ctrl+b — run current file (if possible)
ctrl+alt+p — opens projects list (if you have any)

All currently set combinations can be found under Preferences -> Key Bindings. And obviously, you can modify anything what’s in there and create new ones.

Did I mention you can download it for free?

You can thank the authors by buying the license for it, I’m sure they will appreciate it as much as you will love their product!

Don’t forget to tap and hold 👏 and to follow DaftMobile Blog (just press “Follow” button below 😅)! You can also find us on Facebook and Twitter 🙂

--

--