martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.21k stars 258 forks source link

S behaves like C when repeated with dot command #940

Open climech opened 3 years ago

climech commented 3 years ago

Given file contents:

xxxxAxxxx
xxxxBxxxx

(1) In normal mode, place the cursor at A and do S-<Esc>.

This gives us:

-
xxxxBxxxx

(2) In normal mode, place the cursor at B and use the dot command.

Expected result:

-
-

Observed result:

-
xxxx-

Vis version: v0.7 +curses +lua +tre +acl

ghost commented 3 years ago

The implementation of S is

    { "S",                  ALIAS("^c$")                                },

Since the dot repeat remembers only the last operator, the ^ motion before it is not repeated.

ghost commented 3 years ago

Just found that the alias was originally to "cc" (which can be properly dot-repeated), but was changed - cddf1791, probably so that it preserves indentation. (In Vim, both S and cc preserve indentation. In fact, help S says that it is a synonym for "cc".)

mizlan commented 3 years ago

On a similar note, I find a lot of this aliasing problematic. Take for example O and o, which I ran into problems with while trying to make smarter indentation when pressing those respective keys. This aliasing makes remapping and adding more functionality much more difficult. In addition, the fact that vis always recursively evaluates keymaps makes many features downright impossible. Are there any plans on making nonrecursive keymaps?, because the combination of recursive keymaps + internal aliasing is an problem where there are no workarounds (at least that I know of).