Sublime Text: Basics and Beyond

Sublime Logo

The first step is to download and install Sublime Text

Next, install Package Control by visiting https://packagecontrol.io/installation and following the instructions.

  • Command + ~
  • Then, paste in the code they give you on that page.

Install a theme

Here is one method of customizing the look and feel.

Install the Material Design theme

  • Command + Shift + p
  • Type install
  • Sublime Text Package Manager Install
    Use arrow keys 
    to find Package Control: Install Package
  • Press Enter
  • Type Material Design

Customizing the Material Design theme

Add the theme to your User Settings.

"theme": "Material-Theme-Darker.sublime-theme",
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-OceanicNext.tmTheme",

Additional settings for this theme.

"overlay_scroll_bars" : "enabled",
"line_padding_top" : 2, 
"line_padding_bottom" : 2,
"always_show_minimap_viewport" : true,
"bold_folder_labels" : true,
"indent_guide_options" : [ "draw_normal", "draw_active" ], // Highlight active indent
"font_options" : [ "gray_antialias", "subpixel_antialias" ], // On retina Mac & Windows

 

Install Colorsublime theme manager

  • Command + Shift + p
  • Type install
  • Type colorsublime
  • Press enter

Using another color scheme

  • Command + Shift + p
  • Type install theme
    Sublime Text Install Theme Colorsublime
  • Type Solarized or Facebook
    Sublime Text Install Theme Colorsublime Solarized Ocean
  • Use arrow keys to browse color schemes
  • Press enter on your choice

Customize your Sublime Text settings

Access Settings by navigating to:

  • Sublime Text > Preferences > Settings > User

Keyboard shortcut is Command + ,

Remove minimap from Sublime Text

  • View > Hide Minimap

Remove line numbers

"line_numbers": false,

Customize your font in Sublime Text

To change font size use this setting:

"font_size": 13, 

Download a custom font by visiting the Github repo for Fira Code. Look for the Download Fira Code link and install the font on your system.

"font_face": "Fira Code",

Essential Keyboard Shortcuts

Command+P - find anything in your files

Command+P then Enter will switch back to the previous file.

Command+R - @methods or classes

Command+uparrow - Move to top

Command+W - Move to bottom

Multiple Selection Cursors

Command+D - select multiple instances

Command+U - step backward (undo one of the selections)

Command+Shift+L - select multiple lines and then use this command to split the lines into selections

Command+K, Command+D - Skip an occurence

Command+Ctrl+G - Find all occurrences

Quicker File Creation

Use the Package Manager to install the AdvancedNewFile (ANF) plugin. 

Create a new file Command+Option+N

You can also use a colon (:) for creating a file in the current directory.

  • Command+Option+N
  • :filename.ext

Splitting Hairs with Origami

Use the Package Manager to install the Origami plugin.

  • Command + K starts Origami
    • Command + Arrow Key places a new pane in that direction
      • Example: Command + K then Command + Right arrow will make a new pane on the right
    • Command + Shift + Arrow Key destroys the pane in that direction
    • Command + r lets you resize the panes

You can have Origami automatically zoom the active pane by setting origami_auto_zoom_on_focus in your user preferences. Set it to true for the default zoom, or set it to a user-definable fraction of the screen, such as 0.75.

Origami can also automatically close a pane for you once you've closed the last file in it. Just set origami_auto_close_empty_panes to true in your user preferences.

Linting with SublimeLinter

SublimeLinter is a plugin for Sublime Text 3 that provides a framework for linting code. Whatever language you code in, SublimeLinter can help you write cleaner, better, more bug-free code. SublimeLinter has been designed to provide maximum flexibility and usability for users and maximum simplicity for linter authors. http://www.sublimelinter.com/en/latest/

Macros and Keyboard Shortcuts with SublimeText

To instruct Sublime Text to run macros, you need to pass "run_macro_file" as parameter to "command", with argument being the filename of the macro.

First, merely recording a macro doesn't save it to a file, you'll have to save the macro to a file. This can be done by clicking on Tools → Save Macro & then give a filename. Macros are generally saved in %appdata%Sublime Text 2PackagesUser folder.

Next, to assign the keyboard shortcut, open the Keybindings file from Preferences → Key Bindings - User.

Now, the general format for a keybinding is as below: [source]

{ "keys": [], "command": "run_macro_file", "args": {"file": "Packages/User/.sublime-macro"} }

So, if you want to assign Ctrl+ Shift+ X to a macro which has been saved as "add comma to end", the keybinding line will look like so:

[
    { "keys": ["ctrl+shift+x"], "command": "run_macro_file", "args": {"file": "Packages/User/add comma to end.sublime-macro"} }
]

Sublime Text Keyboard Shortcuts Cheat Sheet

Most of these were found on Scotch.io

Basic

F11 Full Screen
shift + F11 Distraction Free Mode
ctrl + shift + p Command Palette
ctrl + ` Show Console
ctrl + k + b Show/Hide Sidebar
ctrl + / Comment
ctrl + shift + / Block Comment
ctrl + k + u Uppercase
ctrl + k + l Lowercase

Selections

ctrl + d Select Word
ctrl + d Use multiple times to select next instance of the selected word
ctrl + click Create multiple cursors for multi-editing
ctrl + shift + space Expand selection to scope. Repeating keeps expanding.
ctrl + shift + m Expand to brackets
ctrl + shift + j Expand to indentation

Go To

ctrl + p Open file based on name
ctrl + g Go to line number
ctrl + r Go to symbol
ctrl + p THEN @ Open file based on name and search for symbol
ctrl + m Go to matching bracket

Lines

ctrl + l Select line
ctrl + shift + k Delete line
ctrl + ] Indent
ctrl + [ Unindent
ctrl + enter Insert line after
ctrl + shift + enter Insert line before
ctrl + shift + ↑ Swap line up
ctrl + shift + ↓ Swap line down
ctrl + shift + d Duplicate line
ctrl + j Join Line

Code Folding

ctrl + shift + [ Fold
ctrl + shift + ] Unfold
ctrl + k + j Unfold All

Search / Find / Replace

ctrl + f Find
F3 Find next
shift + F3 Find previous
ctrl + shift + f Search all files in a folder
ctrl + h Replace
ctrl + f THEN alt + enter Find a certain term then select them all for multi-editing

Tabs and Window Panes

ctrl + shift + n New Window
ctrl + n New Tab
alt + # Select a Tab (ie alt + 3)
ctrl + w Close Tab
ctrl + shift + # Move tab to a Pane (ie ctrl + shift + 2)
ctrl + # Focus on a Pane (ie ctrl + 2)
alt + shift + 1 One Column
alt + shift + 2 Two Columns
alt + shift + 3 Three Columns
alt + shift + 4 Four Columns
alt + shift + 8 Two Rows
alt + shift + 9 Three Rows
alt + shift + 5 Two x Two Grid

Bookmarks

ctrl + F2 Create Bookmark
F2 Next Bookmark
shift + F2 Previous Bookmark
ctrl + shift + F2 Clear Bookmarks

 

Visit sunny St. George, Utah, USA

Get In Touch

We would love to hear from you.

Please enter your email address.
Please enter a valid email address.
Please enter the verification number.
You have entered a wrong verification number.
Please enter a message.
Please check your message for any errors.
Your message has been sent successfully.
Sorry, error occured this time sending your message.
* required