Learn Sublime Text 3

  1. Opening, Viewing, and Editing Files

    • Touring the interface: There is a menu bar up top on Windows, and for Mac and Windows, a minimap to the right of the screen that shows where in the file you are, along with a tab on the bottom that can release panels for you to use.
    • Switching between files: You can add files to Sublime by dragging and dropping them on it. To switch between file tabs, you hit, on Mac, cmd + 1-9, and for Windows, alt + 1-9; You can also use, on Mac, opt + cmd + ← - →, or shift + cmd + [ or ], or cmd or alt + tab, and for Windows, ctrl + PgUp or PgDn, or ctrl + tab. Hitting ctrl + p (windows), or cmd + p(mac), shows a list of all the files that you have ever opened.
    • Handling encodings and line endings: For curly quotes, Mac: single quote: opt + ], shift + opt + ]; double quote: opt + [, shift + opt + [, Windows: single quote: alt + "0146" number pad, alt + "0145"; double quote: alt + "0148", alt + "0147".
    • Basic editing features: You can do a spell check with your code, and indent your code, and on a CSS or JS document, you can put your cursor next to a curly bracket and hit, on Mac: cmd + m, and on Windows: ctrl + m, it will take you to the matching curly bracket.
    • Clipboard features: When you copy and paste an item, to help with indentation problems, use, on Mac: shift + cmd + v, and on Windows: ctrl + shift + v. If you ctrl + x a bunch of code lines one after the other, to bring it all back, use, on Mac: cmd + k, then cmd + v, on Windows: ctrl + k, then ctrl + v.
    • Working on multiple files at once: You can change the layout so it has one, two, or three columns, so that you can work on multiple files at once. The shortcut for this is, on Mac: cmd + k, then cmd + ↑ or ↓, on Windows: ctrl + k, then ctrl + ↑ or ↓.
    • Working with projects: You can drag a folder into Sublime and it will open a sidebar that shows that file, and all the files inside of it. You can save your files as a project and put it in the folder that it is named after. You can even switch through multiple projects. The shortcut for switching projects is, on Mac: ctrl + cmd + p, on Windows: ctrl + shift + p. Switching through projects, you don't have to save your work because it doesn't reset any changes you have not saved.
    • Finding and replacing: The shortcuts for Find and Replace is: on Mac: cmd + f, opt + cmd + f, on Windows: ctrl + f, ctrl + h. You can also use the up and down arrows to toggle through your Find history. The Incremental Find: cmd + i, ctrl + i, brings you to the line that has the search you typed, and hitting escape can bring the cursor back to where it was. Replace finds the word you want and then you can replace it with a different one. You can even find words across multiple files, using the shortcuts: Mac: shift + cmd + f, Windows: ctrl + shift + f.
  2. Customize Your Editor

    • Changing preferences: If you want to change how Sublime looks, you can go to preferences > Settings and it will pull up all the preferences in Sublime, and you can edit them as you wish. To change font size without going to settings, use these shortcuts: Mac: cmd + + or -; Windows: ctrl + + or -.
    • Recommended settings: The Settings that most people will change anyway on their version of Sublime.
    • Package Control: To add packages to your Sublime, start with installing Package Control. After that you can install many more packages to Sublime.
    • Adding custom color schemes: You can look up some color schemes with the Package Control site, then go to Sublime and do Package Control, Install Package, then find the color scheme you want, then activate it.
    • Adding custom themes: You can do the same thing with themes as color schemes.
    • Creating custom key bindings: You can customize the keyboard shortcuts in Sublime using this.
  3. Power Editing

    • Expanding selections of code: To move one word at a time instead of one letter, use: on Mac: opt + ← or →, on Windows: alt + ← or →, and adding shift, you could select those words too. To select a word that your cursor is on, use: cmd + d, ctrl + d; the whole line with: cmd + l, ctrl + l; you can also select by paragraph if there is space above and below the line, but there is no shortcut for it; to select a whole element tag, use: shift + cmd + a, shift + ctrl + a, and repeatedly doing it will soon select the whole file; in Javascript, the way to do that the above is: ctrl + shift + m, and to select by indentation, use: cmd + shift + j, ctrl + shift + j; to select by scope, use: shift + cmd + spacebar, ctrl + shift + spacebar, and it will select every occurance of that element.
    • Transposing and swapping code: To swap code up or down, use: ctrl + cmd + ↑ or ↓, ctrl + shift + ↑ or ↓.
    • Bookmarking a position in the file: To bookmark text (could work for code too), use: cmd + F2, ctrl + F2, and to clear bookmarks, use: shift + cmd + F2, ctrl + shift + F2.
    • Using the GoTo Anything command: To GoTo anywhere you want in your folders, use: cmd + p, ctrl + p, and if you put a (#) in front of whatever you type, then it will look inside of the current open file, and if you type a word in front of the (#), then it will look inside of the file, even if it is closed, with that name. To go to a line number in an open file, use a (:), then type a number and it will take you there. If you put an (@) sign, then it will show you the list of IDs and classes in that file.
    • Navigating your project by indexed symbols: To go to symbol browsing just hit: cmd + r, ctrl + r, to find a symbol in a project, do: shift + cmd + r, ctrl + shift + r, to use GoTo Definition, use the (F12) key. To jump back to the file you were on, use: Mac: ctrl + -, Windows: alt + -.
    • Using the command palette to access seldom-used shortcuts: To access the Command Palette, use: shift + cmd + p, ctrl + shift + p.
    • Using multiple selections to edit multiple lines simultaneously: To enable multiple selection, use: cmd + click, ctrl + click. to do a faster version of the multiple select, first turn off Mission control by going to System preferences, keyboard, then shortcuts, then turn it off, then once you have done that, the shortcut is: Mac: ctrl + shift + ↑ or ↓, Windows: ctrl + alt + ↑ or ↓, another way to do it with a mouse is to use: Mac: option + click-dragging down or up, Windows ctrl + click-dragging down or up. Another way to multiple select is to select everything you want, then split_select_into_lines: shift + cmd + l, ctrl + shift + l, then move the selections wherever you need them to be.
    • Creating a multiple selection using matches: To quick find all matches to what you typed, use: Mac: ctrl + cmd + g, Windows: alt + F3, then move the cursor to where you need it to be, and do your edits. Another way to quickly select items is: cmd + d, ctrl + d, and to skip ones you don't want to use, do: cmd + k, ctrl + k. To undo the last selection you did, use: cmd + u, ctrl + u.
    • Using multiple selections to edit large amounts of text: Select a paragraph element that has a lot of text and hit ctrl + d, and ctrl + k wherever it needs to, and copy all of it and paste it into a new file to edit. Then select it all again, then ctrl + shift + l to select it into lines, copy and paste into the selection you had before.
    • Switching into Vintage mode to make Sublime Text work more like Vim: To turn on Vintage mode, go to Preferences, settings, then go to the bottom of the default settings, and make it ignore "nothing". Then to officially switch into command mode, hit "esc".
  4. Automation

    • Autocompleting code: To pull up a pop-up of auto-completion elements or properties, use: ctrl + spacebar.
    • Using snippets in code: When you hit tab on an <a> tag, it brings up the whole anchor element, including attributes and the ending tag. The whole thing is a snippet. Snippets are small groups of code that you can tab through to type what you need.
    • Using macros in code: To record and stop recording a macro, use: ctrl + q. To save it, go to Tools, Save Macro, name it whatever it does, then click save. To make a shortcut for it, click Preferences, Key Bindings, then type the code necessary for it to work.
  5. Essential Packages

    • ReadmePlease: Install the ReadMePlease package.
    • ColorPicker and GutterColor: Install the ColorPicker package, and it will help you with choosing colors. Gutter Color is helpful, but it is slightly difficult to get.
    • SideBarEnhancements: You can go ahead and install the SideBarEnhancments package, and it will give a bunch of sidebar options. You could even make the Open in Browser sidebar option have a shortcut. Just go to the ReadMe for SideBarEnhancements, and look for the code to put in your Key Bindings - User file. There are other things that you could also put in your User Preferences file.
    • HyperlinkHelper: Installing HyperLinkHelper will help you type in links without actually typing them. The shortcut for looking it up on google is: Mac: ctrl + shift + cmd +l, Windows: ctrl + alt + shift + l. To wrap a link around some text, use: cmd + shift + l, ctrl + alt + l.
    • Emmet: Installing Emmet, you could type something like this: ul#nav>li.item$*4>a{Item $}, into:
      <ul id="nav">
          <li class="item1"><a href="">Item 1</a></li>
          <li class="item2"><a href="">Item 2</a></li>
          <li class="item3"><a href="">Item 3</a></li>
          <li class="item4"><a href="">Item 4</a></li>
      </ul>
      

      It also allows us to move faster through the code by doing: Mac: ctrl + opt + ← or →, Windows: ctrl + alt + ← or →, it also moves you to the spots in between tags that have no content. There is also command shortcuts for select next/previous items: Mac: shift + cmd + , or ., Windows: ctrl + shift + , or .. This is an even faster way to get through code. There is also a toggle comment command that is already there: cmd + /, ctrl + / and here is Emmets comment command: shift + opt + /, ctrl + shift + /.
    • More packages: Here is a site that has a bunch more packages to use.