Text Editors

Programmers spend most of our time in front of a text editor. Whether it is a standalone editor, or one integrated in an IDE, that’s just what we do.

Back in MS-DOS days, my editor of choice was QEdit, later renamed to The Semware Editor. I loved its configurability, and remapped pretty much everything in it to suit my preferences. Around that time I was also working on Unix systems and used vi there, although only for short editing sessions. I had been exposed to Emacs multiple times (starting with MicroEmacs on the Atari ST), but I could never get comfortable with its crazy keyboard combos.

After Windows 95 came and became my regular environment, the best choice was Ultraedit. Very soon, Microsoft Visual Studio became the compiler and IDE of choice for Win95 development, and its built-in editor proved quite powerful, so I would use Ultraedit for editing files that were not C++.

The big annoyance with Ultraedit was that, being a paid product, it was not readily available everywhere I could go. At work, at someone else’s computer, etc. And it seemed to become more bloated with each version. I started looking for alternatives, and settled with SciTE. SciTE is the editor built around the Scintilla text-editing component / library. It’s a very powerful and extensible text editor, but the default installation is rather barebones and lacks many useful text manipulation tools. I was also bothered by the way it implemented rectangular block selections. So I started looking for alternatives again.

The next editor I used was Notepad++, another editor built around Scintilla. Free, lots of features, and lots of free and easy to install plugins. I was completely comfortable with it, no major complaints. Ok well, yeah, one major complaint actually: the “Find in Files” dialog box was fixed in size, and the space available for the listbox of folders to search in was rather short. It was annoying to work with long, descriptive paths. I changed the dialog size and recompiled the editor, but it sucked to do that for every new version of the editor. The other issue with Notepad++ was that I was using Linux (Ubuntu) both at work and on my netbook, and Notepad++ is 100% Windows-only. Oh, and some of the settings are really awkward to configure. Yeah, a great editor, but a number of annoyances.

In text-mode terminals on Ubuntu I had been using joe for quick edits, but for any significant amount of work I slowly started using (and getting used to) vim again. Since I was restless with Notepad++, I tried getting used to gvim on Windows, but despite its many good points, I just could not stomach it. When working in a GUI, sorry but I need at least decent multi-file support with tabs, Ctrl-N to quickly create a scratch file, and of course my Ctrl-C and Ctrl-V and common GUI shortcuts; gvim’s UI is at odds with everything else in the GUI world.

Then someone pointed me to Sublime Text 2. Great editor, lots of tools, features, and neat details. Works on Windows, Mac and Linux. Supports the notion of projects. Scriptable in Python, awesome! I have been using it on and off for a while to see if I really want to switch to it. It is a commercial product, and I suspect that some of the old ghosts with rectangular block selections and Find in Files will come back and deter me from ST2, but for now I’m enjoying it. I wrote a little plugin to add basic Perforce integration:

# Simple Perforce plugin for Sublime Text 2
# (C) 2011 by Javier Arevalo
# Free for anyone to use, distribute and modify

# Copy this file to ST2's Data/Packages/User/perforce.py
# Add the functions to the Tools menu with the following in a file named
#   Data/Packages/User/Main.sublime-menu:
#    {
#        "id": "tools",
#        "children":
#        [
#            { "caption": "-" },
#            { "command": "p4_edit", "caption": "P4 Edit" },
#            { "command": "p4_revert", "caption": "P4 Revert" },
#            { "command": "p4_add", "caption": "P4 Add" }
#        ]
#    }
# And/or in Data/Packages/User/Context.sublime-menu:
#    { "caption": "-" },
#    { "command": "p4_edit", "caption": "P4 Edit" },
#    { "command": "p4_revert", "caption": "P4 Revert" },
#    { "command": "p4_add", "caption": "P4 Add" }

import sublime, sublime_plugin
import os, stat

def UpdateViewWriteability(view):
	if view.file_name():
		if os.access(view.file_name(), os.W_OK):

# Detect readonly / writable files
# These are both false for non-file buffers
def IsWriteable(view):
	return view.file_name() and os.access(view.file_name(), os.W_OK)

def IsWriteProtected(view):
	return view.file_name() and not os.access(view.file_name(), os.W_OK)

# Event to catch buffer activation and check readonly/writeable
# Note: Running the commands doesn't de- and re-activate the view focus,
# so the ReadOnlyCheck event doesn't fire. We call the function manually
# for each command.
class ReadOnlyCheck(sublime_plugin.EventListener):
	def on_activated(self, view):

# Commands

class P4EditCommand(sublime_plugin.TextCommand):
	"""P4 Edit"""
	def run(self, edit):
		os.system("p4 edit \"" + self.view.file_name() + "\"")

	def is_enabled(self):
		return IsWriteProtected(self.view)

class P4RevertCommand(sublime_plugin.TextCommand):
	"""P4 Revert if unchanged"""
	def run(self, edit):
		os.system("p4 revert -a \"" + self.view.file_name() + "\"")

	def is_enabled(self):
		return IsWriteable(self.view)

class P4AddCommand(sublime_plugin.TextCommand):
	"""P4 Add"""
	def run(self, edit):
		os.system("p4 add \"" + self.view.file_name() + "\"")

	def is_enabled(self):
		return IsWriteable(self.view)

3 thoughts on “Text Editors

  1. I just noticed the new blog!

    Anyway, I still use scite for most editing. It has rough corners, but I’ve become comfortable with them. It is very annoying when they change things for no apparent good reason, though. The last ones: they seem to have broken the undo (yet again) and they changed the shortcut for case-dependent in the search “dialog” from Alt-C to Alt-V. 🙁

    The undo thing thing is scary, but at least it’s not destructive like the one in Visual Studio.

    I’ll give ST2 a try!

  2. hi!
    I’m using Sublime text from a few weeks for php development, it’s smooth, it’s amazing!

Comments are closed.