kakoune

Fork of kakoune, an acceptable text editor
git clone git://git.laack.co/kakoune.git
Log | Files | Refs

design.asciidoc (6204B)


      1 Kakoune design
      2 ==============
      3 
      4 This document describes the design goals for Kakoune, including rationale.
      5 
      6 Interactivity
      7 -------------
      8 
      9 Unlike Vim, Kakoune does not have an underlying line-oriented editor. It is
     10 always expected to be used in an interactive fashion, displaying edited text in
     11 real time. That should not prevent Kakoune from being used non-interactively
     12 (executing a macro for example), but priority should be given to ease of
     13 interactive use.
     14 
     15 Limited scope
     16 -------------
     17 
     18 Kakoune is a code editor. It is not an IDE, not a file browser, not a word
     19 processor and not a window manager. It should be very efficient at editing code.
     20 As a side effect, it should be very efficient at editing text in general.
     21 
     22 Composability
     23 -------------
     24 
     25 Being limited in scope to code editing should not isolate Kakoune from its
     26 environment. On the contrary, Kakoune is expected to run on a Unix-like
     27 system alongside a lot of text-based tools, and should make it easy to
     28 interact with these tools.
     29 
     30 For example, sorting lines should be done using the Unix sort command, not
     31 with an internal implementation. Kakoune should make it easy to do that,
     32 hence the +|+ command for piping selected text through a filter.
     33 
     34 The modern Unix environment is not limited to text filters. Most people use
     35 a graphical interface nowadays, and Kakoune should be able to take advantage
     36 of that without hindering text mode support. For example, Kakoune enables
     37 multiple windows by supporting many clients on the same editing session,
     38 not by reimplementing tiling and tabbing. Those responsibilities are left
     39 to the system window manager.
     40 
     41 Orthogonality
     42 -------------
     43 
     44 Kakoune features should be as orthogonal as possible. For example, in Vim,
     45 there are many ways to modify the buffer: Through normal/insert
     46 mode, command mode, and Vim scripts. In Kakoune, modifying the buffer is
     47 only the job of normal/insert mode.
     48 
     49 That means there should be clear separation of concerns between modes:
     50 
     51  * normal mode is for manipulating the selection and the selection contents.
     52 
     53  * insert mode is for interactive insertion into the buffer.
     54 
     55  * command mode is for non-editing features (opening a file, setting
     56    options...).
     57 
     58 Orthogonality is an ideal; it should not forbid common sense pragmatism.
     59 The +gf+ and +ga+ commands are not strictly selection manipulation commands,
     60 but they do fit nicely with other +goto+ commands, so they are acceptable in
     61 normal mode even though they could arguably be moved to command mode.
     62 
     63 Modes should be orthogonal, as should commands within modes. For
     64 example, Vim uses both +d+ and +x+ to delete text, with minor differences. In
     65 Kakoune only +d+ exists, and the design ensures that +x+ is not needed.
     66 
     67 Speed
     68 -----
     69 
     70 Kakoune should be fast -- fast to use, as in a lot of editing in a few
     71 keystrokes, and fast to execute.
     72 
     73  * Vim is the benchmark here. Most editing tasks should be doable in fewer
     74    or the same number of keystrokes as Vim.
     75 
     76  * Kakoune is designed with asynchronicity in mind. Launching a background
     77    process and using its result when available should not block the editor.
     78 
     79  * Kakoune should be implemented with speed in mind. A slow editor is a
     80    useless one.
     81 
     82 Simplicity
     83 ----------
     84 
     85 Simplicity is nice. Simplicity correlates with orthogonality and speed. It makes
     86 things easier to understand, bugs easier to fix, and code easier to change.
     87 
     88  * *No threading*: multithreading is a hard problem and is not well suited
     89    to a text editor:
     90 
     91    - When we want a direct result, we need to be synchronous with
     92      the user. A 4x speed improvement is meaningless; we need to have an
     93      algorithm which appears instantaneous to the user.
     94 
     95    - When we want an asynchronous result, the processing is best left
     96      to a helper command which can be reused with other Unix tools.
     97 
     98  * *No binary plugins*: shared objects by themselves add a lot of
     99    complexity. Plugins add another interface to Kakoune and go against
    100    orthogonality. The +%sh{ ... }+ and socket interfaces should be made good
    101    enough for most plugin use cases.
    102   
    103    - Rather than writing a plugin for intelligent code completion or source
    104      code navigation, it is better to write an independent helper tool that can
    105      interact with Kakoune through the shell.
    106 
    107  * *No integrated scripting language*: for the same reason as binary plugins.
    108 
    109  * *Limited smartness*: Kakoune should not try to be too smart. Being smart
    110    is often unpredictable for the user and makes things context-dependent.
    111    When Kakoune tries to be smart, it should provide the alternative,
    112    'non-smart' version. For instance, +\*+ tries to detect word boundaries on
    113    the selection, but +alt-*+ opts out of this behavior.
    114 
    115 Unified interactive use and scripting
    116 -------------------------------------
    117 
    118 As an effect of both Orthogonality and Simplicity, normal mode is not
    119 a layer of keys bound to a text editing language layer. Normal mode *is*
    120 the text editing language.
    121 
    122 That means there is no +delete-selected-text+ command that +d+ is bound
    123 to. +d+ *is* the +delete selected text+ command.
    124 
    125 This permits both scripting and interactive use cases to share the same text
    126 editing language. Both use normal mode to express complex editing.
    127 
    128 Besides promoting simplicity by avoiding the introduction of another
    129 layer, this helps ensure the interactive editing language is expressive
    130 enough to handle complex use cases, such as indentation hooks.
    131 
    132 Language-agnostic
    133 -----------------
    134 
    135 Kakoune should not be tailored for writing in a specific programming
    136 language. Support for different languages should be provided by a kak script
    137 file. Built-in language support should be avoided.
    138 
    139 Self-documenting
    140 ----------------
    141 
    142 Kakoune should be able to document its features. Live documentation, along
    143 with an extensive suggestion/completion system, provides the discoverability
    144 which is often lacking in non-GUI tools. As much as possible, documentation
    145 should be integrated with the code so that it stays up to date.
    146 
    147 Vim compatibility
    148 -----------------
    149 
    150 Kakoune is inspired by Vim and should try to keep its commands similar to
    151 Vim's if there are no compelling reasons to deviate. However, self-consistency
    152 is more important than Vim compatibility.