When it comes to editors, the modal interface of vi has long been the epitome of high productivity. Once you get fluent in it, you can navigate and transform text with an unmatched speed and ease, using only a minimum of key presses for each action. The backside is an extreme learning curve, and the fact that it over the decades since its conception, have only grown more and more extensive and complex. It is really overdue for an evolution, which is why e version 2.0 introduces a totally redesigned new command mode.

It is not just a copy of vi’s command mode, even though that was the main inspiration. It integrates it with structural regular expressions (as in Rob Pikes editor Sam) and TextMates scope awareness, ending up with at far more powerful and coherent interface.

Obviously this enables the quick navigation that vi is known for, but the fact that you can make selections, and then enter the selections and have the following commands constrained to these ranges, makes it effortless to do actions that would otherwise be extremely cumbersome.

A Quick Example

Lets say you want to replace all occurrences of the number ‘10′ with ‘11′, but only in the comments of your program. Just type the following:

<esc>                    enter command mode
Vtc                      select contents of all comments (syntax aware)
\                        enter selections
V/10/                    select all matches of ‘10′
r11                      replace with ‘11′

or a slightly more advanced example. Lets say you want swap ‘foo’ and ‘bar’ in your entire source, except in comments and strings:

<esc>                    enter command mode
Yac                      select everything but comments
\                        enter selections
Ya”                      select everything but strings
\                        enter selections
V/(foo)|(bar)/           select all instances of foo and bar
r(?1:bar)(?2:foo)<enter> replace with opposites

At this point it may all read like gibberish, but read on and it will soon be clear. Also note that the editor will give live feedback as you type, interactively showing the selections and ranges, making it much easier to follow what is happening.

Usability

In vi the command mode is expected to be your normal mode from day one, setting up a monumentuous learning curve. In contrast, e expects you to start out with using it just like any other modern editor, using the mouse, menus and keyboard shortcuts, and then only occasionally dipping into the command mode when you really need it’s power. This allows you to gradually get your feet wet and get used to the commands, and as time goes you might find yourself using it more and more, eventually becoming so fluent that it becomes your preferred mode of editing.

Coherence

One of the most important factors when learning a new skill, is the ability to build a mental model of the domain. With vi this can be exceptionally hard, as it has over the years build layers upon layers and a multiple of modes, some of which are totally orthogonal to each other (like the ex cmd line).

In e’s command mode there are only four basic concepts to understand: movements, selections, ranges and actions.

Movements

The movement commands allow for quick navigation in the text. They allow you to keep your fingers on the home row rather than using the arrow keys and gives you a much more expressive way to say exactly where you want to go in the text. All the movement commands can be prefixed with a count that repeats it that number of times. So you could for example use 10w to move ten words ahead or 4/test to move to the fourth instance of the string ‘test’.

The movement commands in e are essentially similar to those in vi, and as there, huge productivity gains can be made by becoming familiar with them and gradually starting to use them during editing. This allows you to avoid constantly having to move your hands back and forth between the keyboard and the mouse.

h/j/k/l    left/down/up/right (arrows)
0/^/$      beginning/soft beg./end of line
w/W        beginning of next word/WORD
e/E        end of next word/WORD
b/B        beginning of prev word/WORD
(/)        beginning of prev/next sentence
{/}        beginning of cur./next paragraph
+/-        go to next/previous line
G          go to line (count), default is eod
|          go to column (count), default is bol
%          go to matching bracket
fc/Fc      find char/backwards
/pattern   find string
?pattern   find string backwards
n/N        repeat search/backwards
*/#        find next/prev instance of current word

Selections

Selections are the doorway to the real power of e’s command mode. Using the basic selection commands you can quickly make the selection you need without needing the mouse:

/pattern/  select pattern
vmovements select from current pos
n,n        select range of lines
atype      select object (inclusive)
ttype      select object (exclusive)

The object selectors allow you to quickly select a logical unit of text. The inclusive version select the entire object including delimiters (think a block) and the exclusive only the contents. Notice that an object type like c (comments), uses the TextMate scope awareness to be correct no matter what language you are using. Here are the available object types:

w  word
s  sentence
p  paragraph
c  comment
"  "string"
'  'string'
(  (block)
{  {block}
[  [block]
<  <block>

Often you will want to make repeated selections. You can do this with either the V command which selects everything matching it’s specification or the Y command which selects everything not matching:

V/pattern  select all matches
V|pattern  select all lines with match
V{scope    select all matching scopes
Vatype     select all objects (inclusive)
Vttype     select all objects (exclusive)
Y/pattern  select everything but matches
Y|pattern  select all lines without match
Y{scope    select everything but scope
Yatype     select everything but objects (inclusive)
Yttype     select everything but objects (exclusive)

Ranges

Ranges allow you to gradually refine your searches and selections in a way that is both intuitive and easy to follow visually. They are created by entering selections with the \ command. The selections can have been made by previous commands or manually selected with the mouse. When you are inside ranges, all following commands, be it movements, selections or actions will be restricted to the range and happen in all ranges at the same time.

Let’s say you have an html document where you want to replace ‘ref’ with ’source’ in all paths. One straightforward way to do it would be like this:

<esc>            enter command mode
V/href=”(.*?)”/  select all hrefs
1\               enter capture 1
/ref/            select ‘ref’
rsource<enter>   replace with ’source’

As you can see in the example above, you can also enter a specific capture by prefixing the enter selection command with a count.

Actions

Actions can be grouped in three types: Actions that enter insert mode, actions that operate on text and actions that operate on selections.

The actions that enter insert mode allows you to go back to normal editing in the editor. Usually they first do a movement or somehow prepare the text for editing:

i             enter insert mode
I/A           insert at beg./end of line
o/O           insert new line below/above
cmovement     change from current pos
C             change to end-of-line
cc            change current line

The text actions modifies the text at the current caret location:

x             delete current char
X             backspace
dmovement     delete from current pos
dd            delete current line
rc            replace char
ymovement     copy
yy            copy current line
p             paste

If there are one or more selections available, the actions will operate on them:

\             enter selections
rsubstitution replace selections
d             delete selections
y             copy selections
p             paste over selections
n/N           move selection to next/prev
n,n           keep a range of selections
Vpattern      keep selections with match
Ypattern      keep selections without match
x             select all matches like current
X             select everything but matches like current
o             move caret to opposite end

Dealing with structured files

One thing that can be really difficult with traditional editors that only offer regular expressions for searching, is dealing with files containing structured data. An example could be a list of books in the refer format, where each record is composed of multiple lines starting with an identifier (like %A for author or %T for title), and records are separated by empty lines.

With e’s command mode this becomes pretty effortless. Let’s say you want find all the titles of books authored by Pike:

<esc>             enter command mode
Y/^\n/            select all records (between empty lines)
V%A.*Pike<enter>  only keep those written by Pike
\                 enter selections
V|^%T             select lines with titles

Conclusion

The new command mode in e does not claim to be as comprehensive or complete as vi’s. After all, vi and it’s descendants has had decades to accumulate features. But it does claim to be simpler and easier to understand while at the same time having the potential for even more powerful interactions with the text.

e2 Released!

August 20th, 2010

e has had a major makeover for version 2.0 and there are not only lots of new features, it builds an entirely new base for future expansion.

New features in this release include:

  • Command Mode
    e2 introduces a powerful new command mode, that allows you to do quick navigation and transformation of the text with just a few key presses. It is not just a copy of vi’s command-mode, even though that was the main inspiration. It integrates it with structural regular expressions and TextMates scope awareness, ending up with at far more powerful and coherent interface.

  • Macros
    You can now record macros for quick automation of repeated actions. You can also save these macros as bundle commands and assign them shortcuts to adapt the editor to your common tasks. This also means that the most of the macros in the bundles from Textmate now works.

  • Language independent API
    The new api allows e to be automated from any language. This can be used in bundle commands for much more advanced and fine-grained extension of the editor. Currently the interface is only defined for python, but more languages are coming.

  • Zen Coding bundle
    Zen Coding is an editor plugin for high-speed HTML, XML, XSL (or any other structured code format) coding and editing. The core of this plugin is a powerful abbreviation engine which allows you to expand expressions—similar to CSS selectors—into HTML code. Check out what it is capable of here.

  • Preview of external webpages
    You can now pin the web preview to external web pages, where it will live update every time you save your documents. This means that you can now preview not only static html pages but also pages which contain templates or are otherwise preproceessed by the server.

  • Lots of performance improvements and bugfixes.

All these new features will be described in much more detail over the next few days. So keep an eye on the blog.

This 2.0 release is a free update for all users that have bought their license within a year. Users with older licenses can buy a discounted update here.

Building e on Fedora 10

April 22nd, 2009

e on fedora

Wim Vander Schelden has written a detailed guide to building e on Fedora 10.

Linux Progress

April 15th, 2009

e on Linux

Since the source was released, there has been quite a bit of progress with lots of outside contributions. Adam Vandenberg has been putting in a lot of work on the build environment on the windows side, and Andrey Turkin and Roman Lisagor have been hard at work on getting the Linux version up and running.

As you can see on the screenshot, it now builds and renders on Linux. Getting the build up and running still takes quite a bit of hand holding, and lots of minor issues will have to be corrected before it is usable for daily work, but if you are familiar with Linux, get the latest source and join in and we will soon have a working release.

Releasing the Source

April 3rd, 2009

As of today, the source of the e text editor is being released. This is the first step in the transformation into an Open Company.

Note that this is not just handing the development over to the community. I am still, and will continue to be, the main developer. Development of the editor will continue and it will still be fully supported in the future.

What the release means is that you can never risk ending up with a product that is totally abandoned, that many more eyes will be there to find and remove bugs, that companies and individuals can themselves add features only they need for inhouse use and that the community can help speed up the development of e and hopefully free me up to work on the more innovative features (of which there are many in the planning stages).

The Open Company License

The source is being released with a clear and very permissive license. It is essentially the well known BSD license with a single extra clause:

Copyright (c) 2009, Alexander Stigsen, e-texteditor.com
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the e-texteditor nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  • Any redistribution, in whole or in part, must retain full licensing functionality, without any attempt to change, obscure or in other ways circumvent its intent.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

I think that too many of us have been in situations where we had to review huge multi-page licenses, with no chance for understanding all it’s implications short of being license lawyers. By basing the Open Company License on a simple and well understood license, it is hoped to make community involvement much easier.

While the addition of the extra clause means that the license can no longer be termed an Open Source License, it is ideal for the open company. It is essentially an issue of mutual respect. If I fully respect your ownership, you will in return respect my right to make a living.

Linux version

There has been many questions about whether the release of the source would make it possible to build a Linux version. The answer is yes. The source does build under Linux, it just needs a Linux version of the ecore library which will be released shortly.

The editor could not have been build without the support of a lot of open source projects (most notably wxWidgets). So to give back, the Linux version will be totally free (as in beer).

So play with the source, and join us in the forum if you have any questions.

The promise of Open Source

The Open Source movement has shown that loose groups of people, each working of their own accord on whatever they feel is important or interesting, can create great software. Not only has this worked for small hobby projects, but also for huge well known projects such as Linux, Firefox and OpenOffice.

“beneath all this there is a titillating promise of an even more fundamental freedom”

It used to be hard to imagine that anything serious could be build without the creation of large hierarchical organizations. But if one thing has really been shown in these recent years, it is that self-organizing groups in many cases can outperform traditional organizations.

There is a lot of talk in the community about the various freedoms that open source confers. But beneath all this there is a titillating promise of an even more fundamental freedom. This is “the real freedom zero”:

The freedom to decide for yourself what you want to work on.

If you do not have this basic freedom, all the others are really irrelevant.

The central dilemma of Open Source is, and has always been, how to make a living doing it. And so far all the proposed solutions seems to have been a surrender of the right of the individual to choose his own work.

Whether the idea is to create a company that offers support, or maybe go to work for a big company that has an interest in improving the product, you will always end up with a boss who has the final say in what you should work on. Of course you might be lucky that it (at least for a time) overlaps with what you are passionate about, but the decision is out of your hands.

Very very few people are in a position where someone is willing to pay them for just following their passions and doing whatever they find most rewarding. For most people (if they even have had the opportunity to find their passion), this has to be delegated to a hobby they can do in their free time, while they make their living in a day job.

Is this really what we wish for? Working all day in more or less boring jobs to bring bread on the table, and then only hacking on what you are passionate about in your precious free time, where you should really be with friends and family.

You could say that this must be how it is meant to be. How could it be otherwise, when the commonly inferred meaning of the word “work”, is to be doing something you don’t really want to do, to make a living? And isn’t this how it is, and always have been, for everybody?

But this is ignoring the long history of the human race. If you look to anthropology you will see that we spend the overwhelming part of our history as tribal bands of hunter-gatherers, where nobody really had the means to force others work for them. Indeed many tribal societies have been found where the whole concept of “work” is non-existent. They simply don’t have a word for it.

“The mass of men lead lives of quiet desperation”

It was not until the agricultural revolution, that it really became possible for individuals to amass a surplus of resources, which made it possible to pay (and force) others to work for them.

There is a very good case to be made for the fact that we are not very well evolutionarily adapted to work for others (with others yes, but not for others), and we only have to look around us to see that it causes a lot of misery. This was what Thoreau alluded to when he stated that “The mass of men lead lives of quiet desperation”.

So this brings us back to the freedom to decide our own work. How do we make this titillating promise become reality? How do we make it possible for individuals to freely work together, just working on what they personally find important, while still making a safe living?

The Way it Ought to Be

One, not very optimal, solution could be starting your own one person company, producing and selling proprietary software (as I and many others have done). This ensures that you are the only one deciding what to do, but it also has several problems.

First of all you are only a single person. This means that you have to do all the work, also the work that you don’t find interesting (but you might find it important enough to want to do it anyways). Also, you are yourself a liability to the company. If anything happens to you, everything stops (as it happened for me when I had some family issues that meant development stopped for several months).

Second, there is still a fundamental disrespect for your customers, who in a very real sense are also taking part in the company. They get a locked down product which they cannot study, or modify beyond what you have explicitly provided for. And while they may be doing a lot of activities that are hugely beneficial for the company (offering support on the forum, word of mouth, sending bug reports, etc..), they get no real reward for their efforts.

Fixing the product issue, is fortunately quite easy. Just give the users the source of the application. Then they can study and modify it to their needs, and if they want to, share their modifications with each other. A simple release form can make them share the ownership of the changes with the company so that they can be included in future versions (without making them loose any rights).

The Open Company

“Totally open. No concept of bosses or employees. Anyone could join in at any time, doing whatever task they found interesting, for whatever time they found appropriate.”

The real question is how to make the users real participants in the company. There is a lot more to be done than just coding. Everything from support to design and marketing could in principle be opened up to free participation. Obviously there are some things where mistakes could have seriously adverse effects on the company, but this is where it would be appropriate with levels of certification (maybe shown kind of like stackoverflow’s badges).

Imagine you had a company like this. Totally open. No concept of bosses or employees. Anyone could join in at any time, doing whatever task they found interesting, for whatever time they found appropriate. How could you possibly find a way to compensate them fairly?

The key is in a technology called Trust Metrics. In essence this is a technique for rating each other, but with the key distinction that the way ratings are calculated makes cheating ineffective. This is a new technology, which has not been applied for this purpose before, but it has already proven itself as the underlying principle behind such well known technologies as Googles pagerank and the certifications on Advogato.

By basing the compensation on continuous rating by your peers, it becomes possible to start out by just participating a bit in your free time, and then gradually, as your ratings increase, spend more and more time on the project. It may eventually come to fully supplanting your day job, becoming your primary source of income, or you may choose to just keep it as something you do on the side. And not only can nobody stop you from participating, there is nobody who can fire you either. This makes it a far more secure way to make a living, where your status is solely dependent on your own ability and effort, rather than on arbitrary decisions from some superior.

“not only can nobody stop you from participating, there is nobody who can fire you either.

You could question the fairness of being rated by your peers like this, but keep in mind that the way it is done in companies now, is pretty much completely opaque, with some boss judging you in a pretty much arbitrary manner. At least here you will have full disclosure of why and how you are being rated. Also, it is not completely unprecedented. There are companies like W.L.Gore, which for decades has used peer ratings as the sole basis for compensation. But they have obviously not been open for free participation.

Making It Real

Throughout time, many people have brought up more or less utopian plans for ways to make a living. But if they are never realized, it really amounts to nothing more than hot air. So to make this real, I am putting my company (from which i currently make my living) on the line. Over the next few months I will gradually be transforming the company of the e text editor into an Open Company.

Since this is an established company, which already has an accomplished product and a large userbase, it has a good base to build on. Therefore the transformation will have to be done step-by-step:

“Over the next few months I will gradually be transforming the company of the e text editor into an Open Company.”

1st step: Releasing the source

The source will be made a available, so that users can study and modify the application for their own needs. If they want to contribute their changes back, they can submit them for review. To discourage piracy, a tiny but essential core (also containing the licensing code), will be kept private (at least until users reach a certain rating). This will gradually be followed by a similar opening of the rest of the company (web site, documentation, bug tracking, etc..)

2nd step: Building the Trust Metric

The basic infrastructure will be set up so that participants can start rating each other. The algorithms and code will be released as open source, so that they can be studied and discussed (and used by others). It will probably need quite some time and tweaking before we reach a fair balance.

3rd step: Compensating Participants

All income in the company (minus operating expenses), will be passed through the trust metric and distributed to participants.

The Future

“a future where everybody has the opportunity to find (or start) one or more open companies in alignment with their passions, and make a living doing what they love.”

Throughout the entire process, I will be blogging about the experience and the individual parts of the transformation. This is kind of a grand experiment, but my hope would be that it can inspire others to either join in and participate, or form their own open companies, so even more opportunities are created.

The end goal is to make “the real freedom zero” a reality. Creating a future where everybody has the opportunity to find (or start) one or more open companies in alignment with their passions, and make a living doing what they love.

If you want to participate in this, join us on the forum, and help us shape the future.

Update: First step is complete. The source has been released.

Here is a screencast with a tutorial on creating your own bundles in e. It uses the todo.txt format as example, which is a simple plain text todo list format created by Gina Trapani, and shows how to add highlighting, commands, completions and snippets.

Creating your own bundles is quite easy in e. The documentation on this is still very limited, but the original documentation on the TextMate bundles format all apply (we just use JSON rather than the apple plist format to define Languages and Preferences).

The resulting bundle has been put on ebundles and can be installed from the bundle manager.

Snippet Pipes

September 16th, 2008

The latest update adds an extension to the snippet format, so that you can pipe the contents of individual tabstops through shell commands. This makes it possble for snippets to be far more interactive.

The syntax is pretty straightforward. Here is a simple example that allows you to directly evaluate ruby code:

 ${1:ruby code|ruby -e "print eval STDIN.read"}

If this snippet is bound to the tabtrigger “ru”, then pressing ru[TAB]1+2[TAB] will result in 3 (without leaving any trace of the intermediate steps). Very handy for doing quick calculations without having to do a mental shift and since you have access to the full language you can do far more than simple arithmetic.

The equivalent snippet for python would be:

${1:python code|python -c "import sys; print eval(sys.stdin.read())"}

The commands are not limited to just reading from stdin. They have access to all the standard environment variables, plus a few snippet specific ones:

  • TM_SNIPPET : contains the entire snippet
  • TM_TABSTOP_n: contains the contents of the individual tabstops

This means that you can make snippets that react on quite complex input from the user. Here is a simple example of a snippet that draws a box in a user defined size:

${0:Draw box ${1:10} times ${2:10}|"$TM_BUNDLE_SUPPORT/starbox.rb"}

It works with the following script placed in the bundles support dir:

#!/usr/bin/env ruby

width = ENV['TM_TABSTOP_1'].to_i
height = ENV['TM_TABSTOP_2'].to_i

height.times do
  width.times {print “*”}
  print “\n”
end

The content is piped to the command at the moment you tab out of a tabstop. The one exception is tabstop zero (the ender tabstop). Since this completes the snippet, the piping happens on entry. In the above snippet, this is used to replace the entire snippet text with the user defined box.

This extension of the syntax is currently specific for e. But if it sees enough use then we can hope that it becomes supported in TextMate as well.

Since publishing the Regular Expression Tutorial, I have received a lot of request for making the accompanying cheatsheet available in a more tangible form. So here it is on mugs and mousepads:

Rss feed to track e updates

March 7th, 2008

The release cycle for e is pretty fast, with new updates coming out every one or two weeks. All updates are announced on the forum, but if you are not a regular there, it can still be hard to keep track.

To help on this situation, user Charles Roper has made an rss feed tracking the e updates:

http://feed43.com/e-texteditor-releases.xml

Add it to your feed reader and you will get automatically notified when new updates are released.