Re: [dev] [RFC] Design of a vim like text editor

From: Maxime Coste <>
Date: Mon, 15 Sep 2014 14:21:25 +0100


Here are a few thought on your design, based on my own experience with Kakoune.

On Sat, Sep 13, 2014 at 04:01:15PM +0200, Marc André Tanner wrote:
> Text management using a piece table/chain
> =========================================
> [...]

While this looks like a nice data structure for editing arbitrary byte
string, you can get much better actual performances if you decide you write
a text/code editor.

regular text is naturally line/column oriented, and storing it in the form of
a dynamic array of lines (with lines being simple strings) works very well and
gives excellent performance once you use (line, column) pairs to reference it.

In practice your user think about text in this line column fashion, which
implies that your text editing will stay mostly line column centric, so
things ends up much simpler when the editing backend itself is matching that.

That said, this is limited to actual text, arbitrary byte sequences do not
map well to this, in which case your piece table seems nice.

> Screen Drawing
> ==============
> [...]
> Window-Management
> -----------------
> In principle it would be nice to follow a similar client/server approach
> as sam/samterm i.e. having the main editor as a server and each window
> as a separate client process with communication over a unix domain socket.
> [...]

The client server thing can stay quite simple if you avoid any synchronisation.
in Kakoune once the connection is done, the client sends keystrokes,
and the server sends display commands. Once you have your poll event loop
(which you will endup having if you want to handle anything asynchrounously)
this integrate very easily.

> Editor Frontends
> ================
> vis a vim like frontend
> -----------------------
> [...]

So it seems you are basically targetting very close to vi interface, I am
always a little sad to see new editors doing that. vi and vim have tons of
good ideas in them, but the editing model has a lot of room for improvement
to get a more consistent and regular interface.

Kakoune is one direction, integrating multi-selection and focusing on
interactive edition, which gave very good results in term of keystrokes count
(it beats vim on several vimgolf challenges). I expect there are lots of
alternatives directions to improve the vi-like user interface, and trying
to improve the implementation without trying to improve the design itself
seems like a waste.

Anyway, best of luck on your project, writing a code editor is a very
rewarding experience.


Maxime Coste.
Received on Mon Sep 15 2014 - 15:21:25 CEST

This archive was generated by hypermail 2.3.0 : Mon Sep 15 2014 - 15:24:07 CEST