Reader small image

You're reading from  Mastering Sublime Text

Product typeBook
Published inDec 2013
PublisherPackt
ISBN-139781849698429
Edition1st Edition
Right arrow
Author (1)
Dan Peleg
Dan Peleg
author image
Dan Peleg

Dan Peleg is an accomplished software engineer. As a former developer in the Israeli Intelligence Force, he holds extensive experience in both defense and robotic industries, and has previously lectured at DefCon conventions. Dan has developed unique algorithms for robotic platforms, specializes in a variety of software platforms, and currently works as the CTO for an American startup company.
Read more about Dan Peleg

Right arrow

Chapter 4. Customization and Theme Development

This chapter will give us the ability to fully customize our Sublime Text's look and feel. We will also customize our own color theme. And as a bonus, we will check out the Split Windows feature.

In this chapter we will cover the following topics:

  • Overriding and maintaining key bindings

  • Understanding Sublime's base settings

  • Beautifying Sublime with colors and themes

  • Mastering Split Windows

Overriding and maintaining key bindings


In the previous chapter, we bound as key combination to our macro. Sublime also gives us the option to bind keys to any command by adding custom key bindings; but what are key bindings exactly? In one sentence:

"Key bindings map key presses to commands."

All of Sublime's key bindings are configurable by JSON-formatted .sublime-keymap files.

Platform-specific key bindings

Key bindings can be different per platform; their filename has to be one of the following:

  • Default (Windows).sublime-keymap

  • Default (OSX).sublime-keymap

  • Default (Linux).sublime-keymap

These file names are platform dependent; this means that the key bindings defined in the Windows keymap file will only work if we are on Windows or other OSes. It is important to know that user-specified key bindings need to be placed in Packages/User/Default (<platform>).sublime-keymap.

Key map file structure

A key map is an array of key bindings. Each key binding contains the following elements:

  • keys...

Understanding Sublime's base settings


As we saw, Sublime Text can be fully customized to fit our needs. It stores its settings in JSON-formatted .sublims-settings files. Sublime will load these settings files in the same order that it loads the keymap files. This means that our settings that are stored in Packages/User will always override all other settings except those that have been changed in the current buffer.

The types of settings' files

Each settings file has a prefix that defines its purpose. These prefixes are names that can be descriptive, such as Preferences (Windows).sublime-settings. This means that the file applies only to Windows. We can also specify the file type in the descriptive name, for example, Ruby.sublime-settings. This means that the file applies only when editing Ruby code files.

Customization walkthrough

In this section, we are going to customize Sublime to fit our coding style. Feel free to change the settings with whatever fits your style.

Adding packages

Let's start...

Beautifying Sublime with colors and themes


Sublime Text can be a beauty! We can change Sublime's visual experience by changing its base settings, color schemes, and themes.

Visual settings

Let's start by tweaking Sublime's settings to change visual elements; for example, we can highlight the current line, change the caret style, show fold buttons, boldface folder names, and highlight modified tabs. We are going to do this by opening our user preferences and adding some visual settings to it. The following numbered bullets refer to the labels on the next screenshot:

  1. "highlight_line": true, "caret_style": "phase"

  2. "fade_fold_buttons": false

  3. "bold_folder_labels": true

  4. "highlight_modified_tabs": true

The following screenshot shows the output of the visual settings:

This is cool but not enough for us; we want Sublime to be more awesome!

Sublime themes

Themes are JSON-formatted files with a .sublime-theme extension. Sublime themes modify Sublime's look and feel by changing icons and IDE colors.

Let...

Mastering Split Windows


Sublime Text includes one of the most useful productivity features that is out there—Split Windows! We all know this from vi and Visual Studio, but how can we split our Sublime? We simply need to memorize some shortcut keys.

Let's split our window into two columns using Alt + Shift + 2 on Windows or Linux and Option + Command + 2 on OS X as shown in the following screenshot:

We got a new empty column. Now, we need to move a file there. We'll do it by pressing Ctrl + Shift + 2 on Windows or Linux and Control + Shift + 2 on OS X as shown in the following screenshot:

This feature is very useful when working with source and header files, or even when comparing two files. We can also open up a grid by pressing Alt + Shift + 5 on Windows or Linux and Option + Command + 5 on OS X as shown in the following screenshot:

To master this skill, we'll need to memorize the following shortcuts:

Summary


By the end of this chapter, we have a beautiful, customized Sublime Text application! We have learned how to bind keys to custom actions and how to split Sublime into rows and columns.

The next chapter is for the vi fans among us; we will introduce Sublime's Vintage feature and learn how we can make Sublime more like vi.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering Sublime Text
Published in: Dec 2013Publisher: PacktISBN-13: 9781849698429
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Dan Peleg

Dan Peleg is an accomplished software engineer. As a former developer in the Israeli Intelligence Force, he holds extensive experience in both defense and robotic industries, and has previously lectured at DefCon conventions. Dan has developed unique algorithms for robotic platforms, specializes in a variety of software platforms, and currently works as the CTO for an American startup company.
Read more about Dan Peleg

Split Windows shortcuts

Windows/Linux

OS X

Single window

Alt + Shift + 1

Option +...