BarCamp on Sublime Text 3

Sublime Text 3

Sublime Text 3

In order to try to improve our skills and share knowledge within the team we are currently trialling weekly, informal ‘BarCamps‘ within the team. Today we had our second, focusing on the code editor Sublime Text 3, which is currently in beta.

I’ve been using Sublime Text for a couple of years now, having moved from Blumentals WeBuilder, which I’d been using for years. I loved WeBuilder, I created loads of code snippets to use in it, I even contributed to developing colour themes for the editor. But I just found that Sublime Text was a more efficient editor for me.

At our BarCamp this afternoon I went through the following:

Install

Available for Linux, Mac and Windows. Download from Sublime Text website. Version 2 is stable; version 3 is in beta.

Package manager

Will Bond has created a tremendous package manager, and curates an impressive repository of packages (add-ons, extensions) for Sublime Text 2 and 3.

Recommended packages

With package manager installed, either go to Preferences > Package Control > Install Package, or Shift+Ctrl+P and type Install.

  • Alignment
  • BracketHighligher
  • ColorPicker
  • DevDocs
  • Emmet (see documentation and screencast by Chris Coyier)
  • jQuery
  • SidebarEnhancements
  • SublimeCodeIntel
  • SyncedSideBar
  • Tag
  • Tomorrow Color Schemes
  • View In Browser

User preferences

One powerful feature of Sublime Text is being able to set user preferences. Preference > Settings — Default will show you all the options available. You can then copy and paste those into Preference > Settings — User to edit them.

A few of my favourite options:

  • “bold_folder_labels”: true,
  • “draw_white_space”: “selection”,
  • “fade_fold_buttons”: false,
  • “highlight_line”: true,
  • “line_padding_bottom”: 1,
  • “line_padding_top”: 1,
  • “show_encoding”: true,
  • “show_line_endings”: true,
  • “tab_size”: 4,
  • “translate_tabs_to_spaces”: true

Keyboard shortcuts

Scotch has a useful page showing Sublime Text keyboard shortcuts. Print pages 2–4 for an easy-to-use cheat sheet.

Create snippets

Code snippets are a really useful way of adding blocks of regularly-used code, and mapping them to keywords which are triggered when you hit the tab key.

There’s a really useful tutorial on Hongkiat.com: working with code snippets In Sublime Text that will get you up-and-running.

Q & A

Two questions that were raised during the session we found answers for:

  1. Can you find a PHP function in any file within a project?
    A combination of SublimeCodeIntel package (Alt+click will open the file in the current project that defines the function), and Shift+Ctrl+F allows you to search within the current project for that function name.
  2. How can I ensure that all .inc files are shown with PHP syntax highlighting?
    Open a .inc file, then View > Syntax > Open all with current extension as…

More tips

Sign up for the Sublime Text Tips email newsletter, or simply browse the site for more top tips on what many regard as today’s best text editor.

If you’ve not already tried it, do give it a try. It’s free to try, USD $70 (approx. GBP £42) to buy.

Advertisements