Introducing Sublime Text

Sublime Text is a text editor -­ a very powerful one. It has some truly useful features right out of the box and a ton of 3rd party packages that you can install to extend the functionality of Sublime Text. In this short blog post, we will look into why you might want to use Sublime Text for your daily coding and how to setup some useful plugins (packages) to get you started.

You can find the download links for Sublime Text below. The build used as a reference for this post is the Beta build.

What’s cool about Sublime Text?

  • Image previewing. You can open most image files for previewing directly in the editor.
  • Multiple cursors. This might take a while to get used to, but  will prove helpful from time to time.
    • CTRL + Click to place a new cursor
    • Double click to highlight a word and then CTRL + D to select the next instance of the word
  • Find (and replace) by Regular Expression. Make complex search criteria.
    Reguglar Expression find

    • CTRL + F to open Find, then ALT + R to toggle Regular Expressions.
  • Find (and replace) in files. Pretty self explanatory, but really useful.
  • Command Palette. You can control most plugins via the Command Palette as well as the built in features of Sublime Text.
    • CTRL + SHIFT + P to open.
    • Type something to start filtering commands.
  • “Go to Anything”. You can quickly jump from file to file and navigate inside a file with your keyboard.
    • CTRL + P to open the console. Type in the name of the file you are looking for. Use @ to navigate in a file.
    • CTRL + R to open the console with @ as prefix to navigate in the current file.
  • Responsive. You can still continue working on other files even while some really huge file is loading in the background.
  • Customization. There’s often a plugin created by someone to get the specific feature you want. There’s also lot of really professional looking themes to make it pleasing to your eye.
  • Runs on Windows, Linux and OSX.

Alternatives

If for some reason you kind of like Sublime Text, but it’s missing that ‘something.’ There are some alternatives that are similar to Sublime Text which are worth a mention:

Installing plugins

Plugins can be installed manually or by using the Package Control. Actually, Package Control is a plugin itself; It’s a must have plugin that will be installed first. We won’t be looking into how to install packages manually, since most plugins have manual installation guide in their manual.

Configuring plugins

You can configure all installed plugins by accessing the configuration file (Preferences -> Package Settings -> [Package Name] -> Settings – User). You might want to look at the default configuration file and the documentation of the plugin to understand what to do as the user configuration file will most likely be empty for you. Unfortunately, there isn’t auto-completion for the configuration files.

Installing Package Control

All you have to do is copy an install code from Package Control’s website and paste it in Sublime Text’s console. You can open the console via the menu (View -> Console) or shortcuts CTRL + ` or CTRL + Ö, depending on your keyboard layout. After the installation, you should get a notification to restart Sublime Text.

Installing plugins with Package Control

Now that you have Package Control installed, you can use it to manage your future plugins. Use the previously mentioned Command Palette (CTRL + SHIFT + P) to manage them. The most basic commands you will mostly be using are:

  1. Install to browse a list of plugins and install them.
  2. Remove to uninstall some of your current plugins.
  3. List to view currently installed plugins.

For example, to install new syntax definitions for Unity C# (colors Unity Engine related words):

  1. Open the Command Palette (CTRL + SHIFT + P).
  2. Type install and select the Package Control: Install Package command.
    Install plugin
  3. Type unity and select the Unity3D syntax highlighting
  4. On the bottom bar of Sublime Text, you should see notification indicating that a package is being installed
    Installing package
  5. Next you might want to look at the package’s documentation to see how it is used. Unfortunately, you have to google the documentation yourself as Package Control does not offer the option to open the documentation page for packages.

Introducing useful plugins

Next we will look into a few useful plugins. Install them by using the Package Control as described before.

OmniSharp

OmnisharpSublime is a plugin for ST3 to provide a C# development environment”.

This is a quote from the plugin’s manual, which describes well what it is and why it’s useful. You can find a more in-depth manual on the GitHub page, here we’ll just take a look at how to get it running quickly.

  1. Install the plugin: OmniSharp.
  2. Open a folder in Sublime Text (File -> Open folder…). Select your C# project (or Unity project).
  3. Save the project (Project -> Save Project As…) in the same location as the solution file (.sln).
  4. Open the project file (.sublime-project) in Sublime Text and insert the following setting:
"solution_file": "./SOLUTION_FILE_NAME.sln"

Replace the SOLUTION_FILE_NAME with the name of the project’s solution file. After this the project file should look something like:

{
    "folders":
    [
        {
            "path": "."
        }
    ],
    "solution_file": "./my-superior-game.sln"
}

This is the most basic way to get the intellisense working. Next we will configure the plugin for better experience.

Launch intellisense on ‘.’ and ‘<' characters

  1. While having C# file open, open syntax specific preferences (Preferences -> Settings – More -> Syntax Specific – User).
  2. Paste the following settings:
{
    "auto_complete": true,
    "auto_complete_selector": "source - comment",
    "auto_complete_triggers": [ {"selector": "source.cs", "characters": ".&lt;"} ],
}

Hide certain files and folders from the project tree

  1. Open the project file (.sublime-project).
  2. Insert the following setting after the path:
"file_exclude_patterns":["*.meta", "*.csproj"],
"folder_exclude_patterns":[".vs", "obj"],

This would hide all files ending in .meta or .csproj and hide all folders named .vs and obj.

Git

Another quite useful plugin would be the Git integration. Once you have both Git and the Sublime Text plugin installed, you are good to go.

  1. Install plugin: Git
  2. Open a cloned project as a folder (File -> Open folder…).
  3. Open the Command Palette (CTRL + SHIFT + P).
  4. Type in Git commands.

Color Highlighter

If you do web development, you will love the Color Highlighter. It simply highlights color codes with the color they are representing like #FF0000, #FF0, rgb(255,0,0), rgba(255,0,0,0.5).

Color Highlighter

  1. Install package: Color Highlighter.
  2. You are good to go.

However, if the plugin does not seem to work, you might need to add following settings for the package (Preferences -> Package Settings -> Color Highlighter -> Settings – User):

{
	"enabled": true,
	"ha_style": "default",
	"file_exts": [".css", ".sass", ".scss", ".less", ".styl", ".html", ".js", ".sublime-settings", ".tmTheme", ".erb", ".haml", ".back", ".py", ".md"]
}

You can also add more file extensions where you want the plugin to do its work.

ColorPicker

Last plugin we look into that you might find useful is the ColorPicker. You can insert color in hexadecimal from a color palette.

  1. Install package: ColorPicker.
  2. Open the picker using the shortcut: CTRL + SHIFT + C.

Installing a theme

Themes are simply packages like everything else that you can install by using the Package Control. We will install the ‘Material Theme’ (https://github.com/equinusocio/material-theme) in this example. We will also install an addon to this theme (https://github.com/equinusocio/material-theme-appbar).

  1. Install a package called Material Theme.
  2. Install an optional package called Material Theme – Appbar.
  3. Activate the theme by inserting following settings to preferences (Preferences -> Settings – User):
"theme": "Material-Theme.sublime-theme",
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",

A restart might be required. There are bunch of recommended settings that you can find from the documentation of the package.

Interested?

We're always up for more discussion or further questions on Twitter.

Share this Post