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

From: Maxime Coste <frrrwww_AT_gmail.com>
Date: Fri, 19 Sep 2014 18:31:35 +0100

Hello,

On Fri, Sep 19, 2014 at 03:13:28PM +0100, Raphaël Proust wrote:
> On Fri, Sep 19, 2014 at 2:22 PM, Maxime Coste <frrrwww_AT_gmail.com> wrote:
> > […]
> > That was one of the motivations for swapping selection and operation order in
> > Kakoune (haters gonna hate...), by decoupling selections from the operator, you
> > can express arbitrarily complex selection operations, you have a (rather limited)
> > version of that with vim visual mode.
> >
> > Once you have that, you can provide the upper level operations by defining them
> > by language in term of basic operations.
>
> From what I understand of Kakoune (correct me if I'm wrong) the
> selection system is a dynamic/interactive equivalent to the structural
> regular expressions of sam/Acme.
>
> 1: Can you comment on the difference in expressiveness? (Assuming you
> tested Acme/sam, otherwise don't bother.)

So, I have not used sam/acme a lot, just played around with them, but basically
we should have a similar expressiveness:

 * select all regex matches/split on matches (in already selected text) is one of
   kakoune basics. This is the equivalent to sam x/y commands.

 * Another building block is keep/remove selections containing a match to a given
   regex.

 * virtually all selection operations are recursive, they are applied to already
   existing selections.

 * Due to multiselections, an operation naturally applies to every selections, so the
   looping nature of x in sam is preserved

In kakoune, x would be s, to remove all instance of 'string' in a buffer you would do
%sstring<ret>d with % selecting the whole buffer, s opening a prompt for a regex (where
we enter string and validate with <ret>), after this ret we have every instance of
string selected. and the d command deletes selected text.

On top of that you have access to vi style movements. so to remove the words following
string, you could replace d with wd in the previous command.

Having the vi style movement probably improves the expressiveness because we can express
things that are notably hard to do with regex (select enclosing { .. } block
respecting nesting for example).

> 2: Does Kakoune have selection macro? I.e., a way to repeat the same
> selection keystroke input. Or even better a way to go and edit the
> selection pattern like q: does for commands in vim. That would
> actually allow to define higher level constructs and reuse them across
> projects of the same language, &c.

Kakoune has vi-style macros (record and replay), they are just a list of keystrokes so they
can select and modify the text.

In addition to that, can map a set of keystrokes to a key in order to add your own
selection primitives.

All the auto indentation in kakoune is implemented as user hooks that triggers keystrokes,
here are a few things we are able to express (from the C/C++ indenter):

 * on newline, increase indent if previous line ends with { or (
 * on newline, align to opening ( if we are in a non closed parenthesis
   (respecting nesting)
 * on closing brace, auto insert the ';' if we are closing a
   class/struct/enum/union

As said in my previous email, the hard part is defining a nice set of operations that gives
this expressiveness without becoming a big mess, in particular when one goal is to stay
interactive (so, 1 key commands as much as possible).


Cheers,

Maxime Coste.
Received on Fri Sep 19 2014 - 19:31:35 CEST

This archive was generated by hypermail 2.3.0 : Fri Sep 19 2014 - 19:36:08 CEST