Skip to content

Differences from Vi(m)

Nick Hanley edited this page Nov 16, 2022 · 10 revisions

Below we list some deliberate differences in behavior compared to vi(m).

Multiple cursors/selections instead of visual block mode

Visual block mode is not implemented, instead vis has builtin support for multiple cursors/selections providing a more interactive experience.

Structural regular expressions instead of Ex mode

Ex mode is not supported, instead we use sam's structural regular expressions based command language.

Lua instead of Vimscript

Instead of the mess that is Vimscript, we use Lua. A well designed, lightweight, general purpose programming language supporting multiple paradigms and featuring an efficient implementation.

POSIX Extended Regular Expressions instead of a custom, non-standard variation

No more {very-,}{no,}magic modes with different semantics and escaping rules. Instead we use the familiar and predictable POSIX Extended Regular Expression variant.

Newline addressability

In vis newlines are directly addressable irrespective of the current mode like any other character of the underlying file.

$ moves the cursor over the new line (not the last character of the line). As a consequence x can be used to join lines.

Cursor positioning when leaving insert mode

Leaving insert mode does not move the cursor one character back. Repeatedly switching in and out of insert mode is idempotent with respect to the cursor position.

Operations like 2itext<Escape> are implemented in terms of itext<Escape>.

See also this related discussion.

Search direction of n and N

These motions currently always search in forward (n) and backward (N) directions irrespective on how the initial search was performed.

The following key mappings should replicate vi behaviour:

 :map! normal n <vis-motion-search-repeat>
 :map! normal N <vis-motion-search-repeat-reverse>

You can apply these changes to the config.h file before compiling vis:

        { "M",                  ACTION(CURSOR_WINDOW_LINE_MIDDLE)           },
-       { "n",                  ACTION(CURSOR_SEARCH_REPEAT_FORWARD)        },
-       { "N",                  ACTION(CURSOR_SEARCH_REPEAT_BACKWARD)       },
+       { "n",                  ACTION(CURSOR_SEARCH_REPEAT)                },
+       { "N",                  ACTION(CURSOR_SEARCH_REPEAT_REVERSE)        },
        { "T",                  ACTION(TILL_LINE_LEFT)                      },

See also issue #470.

Behavior of gn and gN in Normal mode

In vis gn is an alias to vgn and gN is an alias to vgN.

The following key mappings should replicate vim behaviour:

 :map! normal gn nvgn
 :map! normal gN Nvgn

You can also change it in the config.h file before compiling vis.

Searching with t and T

If cursor is before the character being searched for, in vis that character is skipped.

Behavior of %

If cursor is not on a special character ('{', '}', '(', ')', '[', ']' etc), pressing % once will attempt to find one forward. Pressing % again will jump to its match if any. In Vi(m), pressing % once will always combine the two actions together.

Modular design

Clipboard integration, digraph support and a menu used for a file selection dialog and word completion are all implemented as standalone tools.

A lot of vim's builtin functionality seems out of scope for an editor and its implementation has accumulated a lot of cruft over the years.