Sublime Text Shortcuts

Lisa Yoder / @_lisli

Why Am I Giving This Workshop?

  • I knew that Sublime Text had a lot to offer
  • I knew I wasn't using it to its potential
  • I wanted to learn what I was missing out on

All of that to say, I'm not an expert. I'm hoping you learn a little something from me, but I'm also hoping this can be a conversation and that I'll learn something from all of you.

Today we'll cover

  • Keyboard Shortcuts
  • Helpful Packages
  • Preferences & Settings

You can download the slides here.

cmd/crtl + d

  • cmd/crtl + d while selecting one piece of text will find & select all other instances of that text
  • Let's try it — select all the instances of "&" throughout this presentation & type "&" instead.
  • If you need to skip over an instance of whatever you're selecting, use cmd/crtl + k + d
  • If you've gone too far & need to deselect the last selected item(s), use cmd/crtl + u.

cmd/crtl + shift + d

  • cmd/crtl + shift + d duplicates the selected line and adds it below.
  • Let's try it — put your cursor at the end of this line & add another list item to this list. Fancy!
  • This works for larger blocks, too. For example, select an entire <section>, & cmd/crtl + d. Voila — a new section!

cmd/crtl + l

  • cmd/crtl + l selects the entire current line.
  • cmd/crtl + /

  • cmd/crtl + / comments out the entire current line.
  • Editing Multiple Lines

    • To get multiple cursors, hold down opt + cmd/crtl while clicking & dragging through the lines where you need multiple cursors.
    • cmd/crtl + right or left arrows bring the cursor to the beginning or the end of the line, respectively.

    GoTo Anything

    • Rather than digging through folders to find a particular file, use cmd/crtl + p to open GoTo Anything & search for the file you need.

    Find in Files

    • cmd/crtl + shift + f brings up Find in Files
    • Tip: The search results are clickable!

    Command Palette

    • cmd/crtl + shift + p brings up Sublime's Command Palette
    • There's a ton of things you can do with the Command Palette. My current favorite is HTML entities. Select all the '&' in this file & open the Command Palette (cmd/crtl + shift+ p). Search for "HTML Encode Special Characters." So handy!

    Command Palette — Set Syntax

    You can also set the syntax for your current file without digging through the menu at the bottom of the screen. Just bring up the Command Palette & search for "Set Syntax," selecting the appropriate syntax highlighting.

    Packages

    First, let's install Package Control.

    Choose and copy the appropriate Python code.

    In Sublime, cntl + ` to open the console, and paste the Python code.

    Quit & reopen Sublime Text. Now you can install packages!

    Bring up that Command Palette!

    Now when you search for "Package Control: Install Package," you'll find Package Control & a list of possible packages you can add to your Sublime Text.

    You can also browse Will Bond's Package Control to see what else is out there.

    What to Install

    The packages I install most often have to do with syntax highlighting.

    • SCSS
    • Liquid
    • & other syntaxes that aren't included in Sublime out of the box.

    Emmet

    I haven't used Emmet yet, but it looks pretty helpful if you write lots of markup.

    Other Packages of Interest:

    Removing Packages

    Same as installing packages, bring up the Command Palette, search for Package Control: Remove Package, and select the package you'd like to uninstall.

    Packages

    Some of the Packages you install will be added to the Preferences > Package Settings menu, where you can update user settings for those specific packages.

    Preferences & Settings

    Let's go to Preferences > Settings - Default. Don't edit anything, let's just look at what's here.

    Preferences & Settings

    To edit your preferences & settings, make sure to use Preferences > Settings - User. This ensures that your settings won't get overwritten when Sublime Text updates.

    Preferences & Settings

    
    {
    	"binary_file_patterns":
    	[
    	"dest/"
    	],
    	"bold_folder_labels": true,
    	"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
    	"font_size": 14.0,
    	"highlight_line": true,
    	"highlight_modified_tabs": true,
    	"line_numbers": true,
    	"ignored_packages":
    	[
    	"Vintage"
    	]
    }
    						

    Preferences & Settings

    Excluding Files from GoTo Anything & Find in Files

    "binary_file_patterns": [ "dest/" ]

    Preferences & Settings

    Highlight Modified Tabs

    "highlight_modified_tabs": true

    Preferences & Settings

    Saving

    "save_on_focus_lost": false

    Preferences & Settings

    Syntax Specific Settings

    You can create syntax-specific user settings files.

    This is handy if you want different color schemes or different indentation settings for different syntaxes.

    Syncing Your Preferences

    Package Control has a good guide on how to sync your preferences between different machines you may use via Git or Dropbox.

    Want to learn more?

    These are the resources I used to put together this class:

    Questions? Comments? Thoughts?

    Let's chat.

    @_lisli | lisa.alane.yoder@gmail.com

    lisa-yoder.com/slides/WITS2015