Xaprb

Stay curious!

Lessons learned from the Sublime Text editor

with 11 comments

Terminal-based, keystroke-driven editors are enormously powerful, and I still haven’t seen anything more powerful than Vim. I’m a longtime Vim user, and although I’m not the world’s foremost jaw-dropping expert on Vim, I would call myself an advanced power user at the very least, and probably a true expert. Still, I have maintained a relationship with GUI text editors over the years, too. An editor that has an insertion point for a cursor, and “native” mouse interaction, has an appeal I’ve never quite shaken. I’ve used (and been highly productive with) Kate, GEdit, Notepad++, Visual Studio, and many others. I have purchased licenses for Textpad, Textmate, and most recently Sublime Text 2.

Sublime Text is a very nice editor. I’ve chosen it for my recent Go programming because of the GoSublime integration, which uses gocode (which also works for Vim, by the way) to provide IDE-like autocomplete and other helpful functionality, like incremental syntax checking and running gofmt on save. Sublime Text also has a limited Vim emulation mode, which lets me drop into Vim command mode for some mouseless productivity.

Keep in mind that I think Sublime is great, and well worth the license fee. That said, I find its advocates a bit wide-eyed and breathless in their enthusiasm. I keep thinking, Have they never used a decent editor before? Take the “multiple selection” feature. You can select something, such as a variable name, then press Control-D repeatedly and select other occurrences of the same text. Then you can type, and all of the occurrences change simultaneously. Revolutionary! Any praise about multiple selections is an understatement!

Really? You’ve been able to do that with just as few, or even fewer, keystrokes in Vi or Vim forever:

:%s/oldtext/newtext/gc

All you have to do is press a key for every occurrence. If you want to change them all without confirmation, leave off the trailing ‘c’ command to the regular expression. This is basic, not a power-user feature. It’s Unix regex 101 for any number of tools — nothing new to learn here.

Similarly, a number of other purportedly “new” features in Sublime Text 2 are decades old, well-worn and loved in many other text editors. I’ll admit that most of the mouse-based, cursor-insertion-point, GUI text editors don’t offer these types of features in any usable or convenient way; they just seem to lend themselves much better to terminal-based editors like Vim and Emacs. (Example: passing selected text through a shell command and reinserting it into the file.)

In fact, many of these older text editors offer way more functionality than Sublime Text. It doesn’t even come close. The find-and-replace in Vim, for example, is way better than the dialog-based functionality in Sublime Text, or nearly any GUI editor for that matter. Not to mention the documentation; Vim’s documentation and help system is breathtaking, but Sublime Text’s is… uninspired at best. You can compare terminal-based text editors to Sublime Text on a bunch of dimensions and it comes up way, way short. Again, this is just some rambling thoughts — I repeat, I bought the license. And I’m sure Sublime Text is going to continue improving rapidly, as it has been the whole time I’ve been aware of it.

And now we come to my point: it appears to me, from the enthusiastic response to Sublime Text, that a large proportion of the developer population either uses a weak-sauce text editor or is utterly untrained on using a powerful one. How else can we explain the enthusiasm? I honestly can’t think of anything. And this is a really saddening thought, because it means that thousands of programmers have completely neglected one of the most important things they could do: become truly proficient, if not expert, with their text editor. The text editor is to the programmer as the wrench is to the mechanic, as the compass is to the navigator, as the shoe is to the runner. It is arguably the single most important tool you’ll use as a programmer.

There’s just no excuse. If you aren’t using a powerful text editor (and I would count Sublime Text as one), get one. And if you aren’t at least an advanced user of that editor, get a move on it. I’m not the first to say this, but I can’t remember or locate the quotation about this topic that I’m trying to recall. Maybe someone can help out in the comments.

What’s your favorite text editor? What’s your favorite resource for becoming an amazing wizard with it, so that you regularly do the kinds of tricks that make your friends say “hey, what editor is that?”

Written by Xaprb

November 20th, 2012 at 9:14 pm

Posted in Coding,Desktop,Tools

11 Responses to 'Lessons learned from the Sublime Text editor'

Subscribe to comments with RSS

  1. I’ve tried vim as main-editor (hard enough IMO) but given up, mainly because most of the time GUI is enough.

    My 2 most important features are marker-based ({{{, }}}) code folding and direct SFTP editing (file open/save, no “projects”, no local sync), for which I like jEdit better at the moment.

    Edmar

    20 Nov 12 at 10:44 pm

  2. i use sublime too because it is nice for view and it is lightly enough

    jianfengye110

    20 Nov 12 at 11:40 pm

  3. I like Notepad++. Previously, i used textPad.

    com builder

    21 Nov 12 at 5:53 am

  4. I’ve used Kate as my main editor for many years now. I sometimes use vim or even nano, but as you said mouse usage is still difficult to reduce to 0.

    The “sessions” feature from Kate is very useful for me, i.e. the ability to memorize and easily open a given set of files. You can therefore generate those session files, and when you install a new release of a given product, open up the most important config files with a couple of keystores.

    that and terminal integration, powerful regex replace, code folding, completion, configurable syntax coloration, scripting, etc… makes it my editor of choice.

    Romain

    21 Nov 12 at 9:52 am

  5. As a freshman at MIT taking the introductory CS class, the first “lab” assignment was to go through the Emacs tutorial — there were several reasons for the choice of Emacs, including the fact that Emacs was written at MIT, etc. :)

    In any case, this established an environment where all of my classmates, TAs, instructors and professors were comfortable with Emacs, which helped enormously when collaborating with others (pair programming), getting help from instructors, etc. An important benefit was when working with someone more experienced, you get to ask, “How’d you do that… that thing you just did?” Which, by the way, is a great way to quickly come up to speed: Watching how really experienced people use the editor and asking them questions.

    Having said that, different editors have their strengths. I often use Emacs for editing small to medium sized code files where my edits are locally concentrated, and I only need to refer to a few other files.

    I picked up Textmate while working on my dissertation because I found it to work really well for managing complex large LaTeX projects. I loved being able to click on the resulting PDF and have it jump to the corresponding position in the .tex file, and vice versa.

    Finally, I’m spending an increasing amount of time in Sublime. I find it easier to manage groups of files and for quickly navigating unfamiliar code. I particularly like that it works in Linux, and it does a good job of recognizing multiple languages in a single buffer. For example, correctly highlight HTML/PHP/Javascript, and even SQL statements within Python and PHP files.

    Andrew

    21 Nov 12 at 5:02 pm

  6. My editor is Vim. There are some great books and web sites available for learning it, which are easy enough to find. One of the best resources for learning it, though, is the Vim help system. The user manual is based on The Vim Book. If you search for that on Google, you will find the PDF version of the book that Vim’s user manual is based on. If you can be comfortable enough with using Vim to navigate its help system, you don’t need any other resource. But The Vim Book is a great second choice.

    Aside from reading books, practice is the best tool for learning it. Also, using the vi input mode of other programs is very helpful. Bash has this, which is enabled with set -o vi. Firefox has Pentadactyl for Vim emulation. And if you use Okular for reading PDF files, it has partial vi key bindings, which can be expanded for a more complete vi emulation. The idea here is to achieve total immersion into all things vi.

    I think the problem with advocating Vim over other editors is that it is difficult to articulate Vim’s real advantages. Most editors have discrete commands accessed from pull-down menus, tool bars, and dialogs. They work as single-purpose routines that are isolated from other commands. Vim does not work this way. It has a command language that is designed for combining into flexible “sentences” of command words. Each command is a single key, not a control or alt key chord. Because of this, its commands are easy to touch type. Touch typing eliminates the need to look away from the screen as much as when you would to ensure that you are pressing the right keys in a key chord. This translates to faster editing and more focused attention. Those are Vim’s real advantages.

    To get those advantages requires a solid foundation in touch typing and the willingness to give up using arrow keys for navigation. If your idea of typing is to use two fingers while looking at the keyboard, you won’t get much out of using Vim. If you can’t imagine using a computer without touching your mouse, Vim will feel foreign and restrictive.

    But, if you realize that text editors are (or should be) about the text and making easy things easy and hard things possible, it may be worthwhile to take time for leaning to touch type and then learn Vim.

    Scott

    23 Nov 12 at 10:57 pm

  7. I second that — Vim’s help system is amazing.

    Xaprb

    26 Nov 12 at 10:18 am

  8. I came across Sublime Text based on a recommendation and I’m underwhelmed. Ok, I’ve used vi / Vim for over two decades, but still, I don’t see how the screen splitting in Sublime can compare to :split, or :vsplit – as many times as you like, in contrast to Sublime’s “columns / rows” arrangement. Even then, having to use “File -> New View Into File” instead of :b someBufNum leaves something to be desired: I shouldn’t have to Google something like that. Most other GUI text editors have something more obvious than that. I don’t want to bag on Sublime, but that’s not what I consider “cutting edge.”

    To be fair, someone waltzing into Vim for the very first time would probably get very frustrated very quickly, without some sort of guidance.

    I also love Vim’s session files, which must be similar to Kate’s. I had a nasty, ugly legacy project where I absolutely needed Vim’s sessions to track where I was. Ugh.

    Finally, for now, I like how vi / Vim is on every platform I use: Mac, Win, Linux, Solaris, HP/UX, you name it.

    Good luck to Sublime, but I’ll stick with Vim for day-to-day stuff, thank you, and Eclipse for my large projects where I need comprehensive symbol indexing. Maybe the upcoming Sublime Text 3 will be more enticing.

    Aaron

    4 Mar 13 at 2:27 am

  9. I’m sure the upcoming Sublime Text 3 will be amazing. And to go into snark-mode for a moment, it will have 2 new versions of documentation, so there will be 5 incomplete, partially overlapping, half-contradicting sets of docs. One of Vim’s most endearing features is its amazing and comprehensive documentation.

    Xaprb

    4 Mar 13 at 3:27 pm

  10. I get it, you don’t want to leave Vim, in which you are consummate experts, for a new environment where you have to learn lots of new stuff.

    But let’s be realistic for a while. Sublime Text can do a few things that Vim can only dream about. The drawback: it’s a lot easier to use, apparently.

    So no matter what you think of it, Sublime will become absolutely massive in programming circles. Because of all the people who are switching from anything OTHER than vim :)

    Not to invalidate your point, more to explore the context

    xman

    5 Mar 13 at 11:45 am

  11. Are you sure Sublime Text can do so many things Vim can only dream about? I consider myself pretty much a power user with both, and I think Vim is objectively way, way more powerful. The most fundamental difference IMO is that one is a terminal-based editor and the other is a textarea, cursor-based editor. Sometimes I want one, sometimes the other, it just depends on the task. But that difference has little to do with their abilities.

    Xaprb

    5 Mar 13 at 6:00 pm

Leave a Reply