Sublime Text

Summary

When coding, writing up blog post, or doing any other task, I generally have used Notepad++. It is a great program that automatically detects, based on the extension, the type of code you are writing and parses the file accordingly. It is light and gets the job done, but it always felt like it could be taken to the next level. Enter Sublime Text 2, a program that seems to have everything I am looking for in a text editor and then some.

When coding, writing up blog posts, or doing any other tasks, I generally use Notepad++. It is a great program that automatically detects, based on the extension, the language you are coding in and parses the file accordingly. It is light and gets the job done, but it always felt like it could be taken to the next level. Enter Sublime Text 2, a program that seems to have everything I'm looking for in a text editor and then some.

For starters, Sublime Text is endlessly customizable and comes with several powerful features such as Snippets, Plugins, and Packages. Snippets allow you to execute a bit of code when you enter any sequence of letters followed by TAB. Else, you can do what I did and map the Snippet to a keyboard combo and BAM, you suddenly can be doing quick substitutions for repetitive bits of code all day long.

There are other superb features, like the ability to hold down CTRL and click the mouse in multiple locations. This creates multiple cursors that you can type in. Suppose there are several lines of code or in a document that you want to change. This allows you to do that and avoid having to deal with regular expressions if you forget the commands. There is CTRL+R that allows you to search your document by functions (alternatively you can type CTRL+P then @) or CTRL+P then type #, which gives you a list of different elements in your document (e.g. different tags if working with HTML). The same command and typing in a colon (or CTRL+G) allows you to jump around to any line in the document. There are a wealth of other features: Distraction Free mode, where everything disappears but the text; a built-in spell-checking that is an improvement over Notepad++'s ghetto one; and multi-column viewing, the ability to line-up multiple documents side-by-side without having to open new windows. And I've only begun to scratch the surface. More can be found on the official website.

Packages allow you to extend the functionality of Sublime Text 2 in different ways. For example, there is Sublime Package Control that allows simple installation of packages. You can browse packages at Sublime Text Packages or contribute via the Sublime Text GitHub group. Some packages allow you to align your documents while other add whole new features.

Notepad++ had a great plugin called WebEdit that allowed you to insert different HTML tags into your documents without having to type everything out. Sublime Text autocompletes many common functions in whatever language you are coding in, but selecting items and interting tags based on those selections was lacking. Thus, after switching to Sublime Text, I missed WebEdit's features and created HTMLEdit to resolve this problem. It has several of the basic tags built in with shortcuts using ALT + [first letter of tag]. It is currently being updated on the HTMLEdit GitHub repository. Below is a sampling of the code, quite simple really.

Javascript
  1. //Default keymap file.
  2. { 'keys': ['alt+a'], 'command': 'insert_snippet', 'args': {'name': 'Packages/HTML_Edit/URL.sublime-snippet' }},
  3. { 'keys': ['alt+s'], 'command': 'insert_snippet', 'args': {'name': 'Packages/HTML_Edit/STRONG.sublime-snippet' }},
  4. { 'keys': ['alt+p'], 'command': 'insert_snippet', 'args': {'name': 'Packages/HTML_Edit/PARA.sublime-snippet' }},
  5. { 'keys': ['alt+e'], 'command': 'insert_snippet', 'args': {'name': 'Packages/HTML_Edit/EMP.sublime-snippet' }},
  6. { 'keys': ['alt+i'], 'command': 'insert_snippet', 'args': {'name': 'Packages/HTML_Edit/IMG.sublime-snippet' }},
  7. { 'keys': ['alt+q'], 'command': 'toggle_setting', 'args': {'setting': 'spell_check'} }
XML
  1. <!--URL.sublime-snippet, insert a URL into page at SELECTION.-->
  2. <snippet>
  3.         <content>
  4.                 <![CDATA[<a href='${1:URL}' target='_blank'>${SELECTION}</a>]]>
  5.         </content>
  6. </snippet>

I'll continue using Sublime Text and report back on any interesting new features and other additions I find. The program is very portable due to instant detection of changes to packages and settings. All these changes can be made within Sublime Text and are easy-to-read plaintext files. Sublime Text 2 is superb and after more than a week using it, I decided to support further development by purchasing a license. Rare that. Give it a try: Sublime Text 2.

-biafra
bahanonu [at] alum.mit.edu

more articles to enjoy:

janelia journal club #1
15 june 2011 | science

Alyson Yee and I gave the first presentation of the Janelia Undergrad program. The paper tried to tease apart the different aspects of a so[...]ngbird's appearance that most influenced behavior of other birds.

why we need more james polks
25 september 2012 | politics

James J. Polk expanded the territory of the United States by about one-third during his tenure. A remarkable feat. Not only that, but i[...]t was done through an astonishing three ways: territorial conquest, gold and negotiation.

Some thoughts on why we should demand less rhetoric and more pragmatism/details from our presidents.

week 5 and 6 | once again
21 july 2012 | singapore

Sometimes it feels like life should have a record button that nicely parses the endless stream of awesomeness that comes at you. Not a came[...]corder or microphone, but a program that understands the world, can automatically find and retrieve the most useful links then type-up a nicely formatted document to present to others. Alas, while some of this technology exist, it isn't in one nice little package. Plus, writing about Singapore is almost as fun as experiencing it. Below are some finds from my fifth and sixth week in Singapore, from adventures in Bali to savouring the taste of Ayam Goreng Pedas Ramen (super spicy!).

©2006-2024 | Site created & coded by Biafra Ahanonu | Updated 17 April 2024
biafra ahanonu