de icon indicating copy to clipboard operation
de copied to clipboard

vi keybindings not always faithful

Open driusan opened this issue 8 years ago • 2 comments

Some vi-style keybindings aren't properly implemented, or at least aren't implemented in the same manner as vi (for instance, l and h don't stop at line boundaries, and there seems to be a nasty bug in dd where ndd deletes 1 too many lines, and dd without a number doesn't delete the whole line.

This results in some commands working unexpectedly, and is a little confusing until you get used to it. There should be automated tests to ensure that they work as expected and don't have any more regressions.

p also acts as P for ergonomic reasons, which should be documented. (I never use p but use P all the time in vim.)

driusan avatar May 18 '16 00:05 driusan

so, there's infinite keybindings in vim, but at least nvi has a constrained set. here's the output of nvi's :viusage:

^A search forward for cursor word
^B scroll up by screens
^C interrupt an operation (e.g. read, write, search)
^D scroll down by half screens (setting count)
^E scroll down by lines
^F scroll down by screens
^G file status
^H move left by characters
^J move down by lines
^L redraw screen
^M move down by lines (to first non-blank)
^N move down by lines
^P move up by lines
^R redraw screen
^T tag pop
^U half page up (set count)
^V input a literal character
^W move to next screen
^Y page up by lines
^Z suspend editor
^[ <escape> exit input mode, cancel partial commands
 ^\ switch to ex mode
^] tag push cursor word
^^ switch to previous file
   <space> move right by columns
 ! filter through command(s) to motion
 # number increment/decrement
 $ move to last column
 % move to match
 & repeat substitution
 ' move to mark (to first non-blank)
 ( move back sentence
 ) move forward sentence
 + move down by lines (to first non-blank)
 , reverse last F, f, T or t search
 - move up by lines (to first non-blank)
 . repeat the last command
 / search forward
 0 move to first character
 : ex command
 ; repeat last F, f, T or t search
 < shift lines left to motion
 > shift lines right to motion
 ? search backward
 @ execute buffer
 A append to the line
 B move back bigword
 C change to end-of-line
 D delete to end-of-line
 E move to end of bigword
 F character in line backward search
 G move to line
 H move to count lines from screen top
 I insert before first nonblank
 J join lines
 L move to screen bottom
 M move to screen middle
 N reverse last search
 O insert above line
 P insert before cursor from buffer
 Q switch to ex mode
 R replace characters
 S substitute for the line(s)
 T before character in line backward search
 U Restore the current line
 W move to next bigword
 X delete character before cursor
 Y copy line
ZZ save file and exit
[[ move back section
]] move forward section
 ^ move to first non-blank
 _ move to first non-blank
 ` move to mark
 a append after cursor
 b move back word
 c change to motion
 d delete to motion
 e move to end of word
 f character in line forward search
 h move left by columns
 i insert before cursor
 j move down by lines
 k move up by lines
 l move right by columns
 m set mark
 n repeat last search
 o append after line
 p insert after cursor from buffer
 r replace character
 s substitute character
 t before character in line forward search
 u undo last change
 w move to next word
 x delete character
 y copy text to motion into a cut buffer
 z reposition the screen
 { move back paragraph
 | move to column
 } move forward paragraph
 ~ reverse case

josephholsten avatar Jun 09 '16 06:06 josephholsten

acme, of course, doesn't have as nicely documented keybindings. And it had been a while since I had to find them in the source, I forgot how hard it was to find the first time. But at least they're all in one humongous switch: https://github.com/9fans/plan9port/blob/master/src/cmd/acme/text.c#L657

Short version, ignoring motion commands, is:

^A: beginning of line
^E: end of line
%C: copy
%Z: undo
%X: cut
%V: paste
^F: complete
^H: erase character
^U: erase line
^W: erase word

Where ^ means Control, and % means Control or Command or whatever the reasonable windows meta happens to be.

josephholsten avatar Jun 09 '16 06:06 josephholsten