AADL Logo Advanced Aircraft Design Lab

Royal Military College of Canada

Sublime Text 2 Startup Guide

Authors SA - Stephen Andrews
Rev 1.0 19-07-2013

This page is indented as a summary of common Sublime Text 2 (ST2) shortcuts.

Sublime Text 2 Shortcuts

General

Command Use
Navigation
ctrl + fwd Move forward one word
ctrl + up/dn Move up/down 45 lines
ctrl + shift + fwd Select next word
ctrl + l Expand selection to entire line
shift + home Select to start of line
shift + end Select to end of line
ctrl + ‘m’ Go to matching bracket
ctrl + tab To to next open tab
rmouse + mwheel Scroll through open tabs
Bookmarks
ctrl + F2 Toggle bookmark on current line
F2 Next bookmark
shift + F2 Previous bookmark
ctrl + shift + F2 Clear all bookmarks
Windows
ctrl + ‘w’ Close window
F6 Toggle spell check
ctrl + shift + ‘p’ Open command pallet
alt + shift + n Side - by -side editing with n windows
ctrl + shift + n Move file to window n
ctrl + k + ctrl + ‘b’ Toggle sidebar
Search
ctrl + ‘f’ Find in file
ctrk + shift + ‘f’ Find in project
ctrl + ‘e’ Find selection
ctrl + ‘h’ Find / replace
ctrl + shift + ‘e’ Find / replace selection
F3 Find next forward
shift + F3 Find next reverse
ctrl + F3 Find next occurrence of selection
ctrl + shift + F3 Reverse Find next occurrence of selection
ctrl + r Search the class / def list in the file
ctrl + p Find Any file in the current project
-@ Search the class / def list in the selected file
-# Search all text in the slected file
-: Go to line number in the slected file
Mutliple Edits
ctrl + ‘d’ Select next instance of highlighted text
ctrl + ‘k’ + ctrl ‘d’ Skip current instance and go to next
ctrl + shift + ‘d’ Duplicate line
ctrl + shift + L Multiple edits on each line of a selection block
ctrl + alt + up/dn Multiple edits along a column
alt + F3 Find all occurrences of selection and multi -edit
Text Manipulation
ctrl + / Toggle comment
ctrl + [ Un-indent line / selection
ctrl + ] Indent line / selection
ctrl + shift + up/dn Swap line up / down
ctrl + ‘l’ Select entire line
shift + del Delete line
ctrl + del Delete word
ctrl + shift + del Delete to end of line
ctrl + shift + ‘j’ Select the entire indentation
ctrl + shift + ‘m’ Expand selection to brackets
ctrl + shift + ‘a’ Expand seclection to tag
ctrl + shift + space Expand selection to ‘scope’
ctrl + ‘a’ Close tag
ctrl + ‘y’ Redo last command
ctrl + j Join lines
ctrl + t Transpose (characters within word, word in line)
ctrl + ‘k’ + ctrl + ‘u’ Convert selection to UPPER CASE
ctrl + ‘k’ + ctrl + ‘l’ Convert selection to lower case
ctrl + alt + ‘a’ Align selection along first ‘=’ sign

Python

Command Use
F8 Dispatch python script to interpreter
F7 Launch a python interpeter
NotImplementedError Set command line arguments
NotImplementedError Dispatch python script to a new focus group

LaTex

Command Use
alt + shift + ‘j’ Show the location of the current text in the PDF
alt + shift + ‘c’ Make the highlighted text a command
alt + shift + ‘n’ Make the highlighted text an environment
ctrl + ‘r’  
  • S
Search sections
  • L
Search labels
ref_ + ctrl + space Show a list of valid references, autocomplete reference
cite_ + ctrl + space Show a list of valid citations, autocomplete reference

Regex Syntax

For those who are not 1337, this is a list of the regex characters recognised by both python and ST2

Char Function
Basic Commands
. Any single character except a newline
^ The beginning of the line or string
$ The end of the line or string
Specifiers
* Zero or more of the last character
+ One or more of the last character
? Zero or one of the last character
{n} N of the last character
{n,} N or more of the last character
{n,m} At least n but not more than m of the last character
Ranges
[A-Z] Matches all upper case letters
[abc] Matches either a or b or c
[^b] Does not match b
[^a-z] Does not match lower case letters
Representing special characters
\. A dot
\| Vertical bar
\[ An open square bracket
\) A closing parenthesis
\* An asterisk
\^ A hat
\\ A backslash
\{ A curly brace
Abstract Commands
\n A newline
\t A tab
\w Any alphanumeric (word) character,
`` `` A short form for [a-zA-Z0-9_]
\W Any non-word character, same as [^a-zA-Z0-9_]
\d Any digit, same as [0-9]
\D Any non-digit, same as [^0-9]
\s Any whitespace character (space, tab, newline)
\S Any non-whitespace character
\b A word boundary, outside [] only
\B No word boundary

Sublime Text Setup

Packages

  1. Package Control
    • Use: Best way to install new packages.

    • Package Control Source

    • Installation:
      1. Open the console (ctrl + ‘)

      2. Paste:

        import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None;    urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.   replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
        
      3. Execute. Execute. Execute.

  2. Sublime REPL
    • Use Allows interactive python windows to open (Build windows are not interactive)

    • Sublime REPL Source

    • Installation:
      1. Package Control: Install Package
      2. SublimeREPL
  3. Tortoise (Windows only)
    • Use: Allows you to update/commit in the sidebar

    • Tortoise Source

    • Installation:
      1. Package Control: Install Package
      2. Tortise
  4. Align
    • Use: Aligns text along the ‘=’ character

    • Align Source

    • Installation:
      1. Package Control: Install Package
      2. Alignment
  5. Terminal
    • Use: Allows a terminal to be oppened in any folder from the sidebar

    • Terminal Source

    • Installation:
      1. Package Control: Install Package
      2. Terminal
  6. LaTeXtools
    • Use: Build scripts and shortcuts for LaTeX

    • LaTeXtools Source

    • Installation:
      1. Package Control: Install Package
      2. Terminal
      3. Follow instructions in the README file
  7. SODA
    • Use Pretty theme for the editor

    • SODA Source

    • Installation:
      1. Package Control: Install Package

      2. Theme - Soda

      3. Preferences: Settings - User

      4. add:

        "theme": "Soda Dark.sublime-theme" or "theme": "Soda Light.sublime-theme"

Keyboard Shortcuts - User

{ "keys": ["ctrl+up"], "command": "scroll_lines", "args": {"amount": 45.0 } },
{ "keys": ["ctrl+down"], "command": "scroll_lines", "args": {"amount": -45.0 } },

{ "keys": ["f8"], "command": "repl_open",
                 "caption": "Python",
                 "mnemonic": "p",
                 "args": {
                    "type": "subprocess",
                    "encoding": "utf8",
                    "cmd": ["python", "-i", "-u", "$file"],
                    "cwd": "$file_path",
                    "syntax": "Packages/Python/Python.tmLanguage",
                    "external_id": "python"
                    } }

Peferences Settings - User

{
    "auto_complete_delay": 50,
    "color_scheme": "Packages/Color Scheme - Default/All Hallow's Eve.tmTheme",
    "dictionary": "Packages/Language - English/en_GB.dic",
    "font_size": 13.0,
    "ignored_packages":
    [
        "Vintage"
    ],
}

Colour Scheme

Make a coppy of <~PackagesColor Scheme - DefaultAll Hallow’s Eve.tmTheme> and move it to the User folder Replace the Text base code with this:

<dict>
    <key>name</key>
    <string>Text base</string>
    <key>scope</key>
    <string>text</string>
    <key>settings</key>
    <dict>
        <key>background</key>
        <string>#000000</string>
        <key>foreground</key>
        <string>#CCCCCC</string>
    </dict>
</dict>

Snippets

  1. pyACDT / pyOpt documentation list:

    <snippet>
        <content><![CDATA[
    - ${1:-name-} -> ${2:-TYPE-}: ${3:-Description-}. *Default: ${4:-Value-}*
    ]]></content>
        <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
        <tabTrigger>item-pyList</tabTrigger>
        <!-- Optional: Set a scope to limit where the snippet will trigger -->
        <scope>source.python</scope>
    </snippet>
This web site is not an official publication of the Royal Military College of Canada nor the Department of National Defence
Ce site web n’est pas une publication officielle du Collége militaire royal du Canada ni du Ministère de la défense nationale