Sublime Text Editor

My favourite shortcuts

I think almost every programmer has his own favourite text editor. Some people like Vim, some people like Notepad++ and I love Sublime Text. There is a lots of useful shortcuts, snippets and plugins which allow in fast and easy way work with code or simple text.

  1. I can see up to 4 file in the same time.

    Sublime has option to see more then one file at the same time. If you add Origami plugin, you can have event more then 4 panels. To use basic Sublime splitting panels you just go to View -> Layout and you can choose which layout you like or you can also see shortcuts for that. I like to have two files open. First with code and second with tests. This is very useful when you work in TDD. You don't need to switch between windows.

  2. Everything is customizable

    You just go to Preferences -> Settings. There is everything you will need for customization. Colors, behaviors, everything. I recommend also to go through other setups in Preferences menu. Spectialy Packages.

  3. Adding new packages

    If you like you can extend Sublime behaviors by installing new packages. You can look at some of my favorites packages:

    • Emmet - for fast and easy creation of HTML or CSS
    • BracketHighlighter - to show you where you start and end brackets, this is nice specialy when you have programming language like JavaScript
    • Git Gutter - to show which part of code are changed or added (integration with git, see what is git article)
    • SublimePrettyJson - formatter for JSON, this is very useful when you have JSON in one line and you would like to read it easly
    • RuboCop - to show good practices in Ruby
    • Linters (Coffee Script, CSS, Sass, JS) - tools which shows good practices in different languages
    • Colorful syntaxt - you can add colors for different programing language syntax, when you don't have specific colorization just install it

    For more plugins checkout in the Internet.

  4. Shortcuts, shortcuts, shortcuts

    To be honest I love shortcuts. This is the reason why I write this article. As long as I can work without mouse, only using keyboard then it's better. This is less time consuming then mouse usage. And Sublime has very useful shortcuts. You can see below:

    • ctrl + k + b - toggle side bar
    • ctrl + 0 - go to side bar with folders (then you can use arrows to navigate between folders and files, enter ↩ opens selected file and move focus to this file)
    • ctrl + 1,2,3,4 - move focus between open panels/group (it depends layout you choose)
    • ctrl + ←, → - go to word beginning/ending
    • ctrl + shift + ←, → - select last/next word
    • ctrl + m - jump to closing/opening bracket for current code
    • ctrl + shift + m - select all contents of the current brackets (curly brackets, square brackets, parentheses)
    • ctrl + PgUp, PgDn - go to last/next open tab (file)
    • ctrl + tab - next used tab/file open in one panel
    • ctrl + shift + tab - last used tab/file open in one panel
    • ctrl + ↑, ↓ - move file up/down by one line (like scroll)
    • ctrl + shift + ↑, ↓ - switch lines in neighbourhood, first line goes up, second goes down
    • crtl + / - comment/un-comment line (it depends selected programming language)
    • ctrl + delete - remove all next words (without adding to clipboard)
    • ctrl + backspace - remove all words before (without adding to clipboard)
    • ctrl + k + k - remove all next words (without adding to clipboard)
    • ctrl + shift + k - remove line (without adding to clipboard)
    • ctrl + ↩ - insert line after
    • ctrl + shift + ↩ - insert line before
    • ctrl + j - join line below to the end of the current line
    • ctrl + alt + j - preatty JSON power by SublimePrettyJson
    • ctrl + ] - indent current line(s)
    • ctrl + [ - un-indent current line(s)
    • ctrl + a - select all file
    • ctrl + l - select all line
    • ctrl + d - select word (repeat select others occurrences in context for multiple editing)
    • ctrl + shift + d - duplicate line(s)
    • ctrl + k + u - upper case
    • ctrl + k + l - lower case
    • ctrl + c - copy selected text to clipboard or when you have cursor in line without selected text copy all line to clipboard
    • ctrl + v - paste selected text or all line from clipboard
    • ctrl + x - cut selected text or all line (when text is not selected) to clipboard
    • ctrl + g - go to line in current file
    • ctrl + ; - go to word in current file
    • ctrl + r - look for symbol (functions, method name, classes) in the file
    • ctrl + shift + r - look for symbol (functions, method name, classes) in all projects
    • ctrl + t - replace letter in neighbourhood
    • ctrl + shift + t - open last closed tab (just like in your browser)
    • ctrl + h - replace one phrase to another in current file
    • ctrl + f - search in file
    • ctrl + shift + f - search in all project (directory), you can also replase phrase in this project
    • ctrl + q - close Sublime completly
    • ctrl + w - close current file/tab
    • ctrl + shift + w - close all window
    • ctrl + n - open new tab
    • ctrl + shift + n - open new window
    • ctrl + s - save file
    • ctrl + shift + s - save as (you can choose new name of file)
    • ctrl + o - open file
    • ctrl + shift + o - open new directory
    • ctrl + p - quick-open files by name in your project (you can search by first letters of each part of file name example: searching mnf sublime will find my_new_file.txt)
    • ctrl + shift + p - command line and package installer
    • ctrl + z - undo you last change
    • ctrl + shift + z - redo your last change
    • ctrl + y - do one more time last action
    • f6 - check spelling base on set dictionary (in my case english)
    • f9 - do alphabetical order of selected lines
    • f3 - next searched phrase
    • f3 + shift - last searched phrase

I hope you find this useful. See you next time!