moar icon indicating copy to clipboard operation
moar copied to clipboard

Keybindings to less / vim

Open inoperable opened this issue 2 years ago • 12 comments

Any way to change default keybindings? I very like the pager but im so used to less vimish keys i would love to set those in moar as well.

inoperable avatar Nov 19 '22 13:11 inoperable

Which key bindings are you missing specifically?

walles avatar Nov 21 '22 10:11 walles

Vi/m hjkl style defaults: h - left, j - down, k - up, l - right, G - bottom, gg - top alternative: hjkl as above but instead of G/gg: y - page down, u - end, i - home, p - page up / - search, n - next match, N - previous match

a lot of term utils use vim style by default or let you easily fall back to that style (incl. shells) moar shouldn't reinvent a proven concept and become a muscle memory irritant :-)

Implementing a Keybinding settings with some default layouts as an example, that would be the optimal solution - so users can configure it to their needs.

On Mon, Nov 21, 2022 at 11:00 AM Johan Walles @.***> wrote:

Which key bindings are you missing specifically?

— Reply to this email directly, view it on GitHub https://github.com/walles/moar/issues/107#issuecomment-1321796445, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL7SAQLCMGM6XWFZBDZ2ZTWJNB3LANCNFSM6AAAAAASFKGH4Q . You are receiving this because you authored the thread.Message ID: @.***>

inoperable avatar Nov 21 '22 12:11 inoperable

What you describe does not match less's behavior, at least not out of the box.

Do you have some specific less config to get these bindings?

walles avatar Nov 21 '22 17:11 walles

I very like the pager but im so used to less vimish keys i would love to set those in moar as well.

+1

Do you have some specific less config to get these bindings?

None, it's the out-of-the-box config - just that the usual readline(3) binds like Ctrl-N for next line, Ctrl-P for previous, Alt-< and Alt-> for beginning/end of file work in less, and not in moar (and they do in other replacements like most.

rbutoi avatar Nov 27 '22 22:11 rbutoi

@rbutoi I just tried what you said in less and:

  • ^p and ^n worked as you describe, so I added them
  • ALT-< and ALT-> had no effect, and I also get them as and which probably won't work on all systems, so I don't see how to implement those reliably

Also, neither Alt-< nor Alt-> are documented on the help screen of less (press h to view it).

walles avatar Nov 28 '22 06:11 walles

ALT-< and ALT-> had no effect, and I also get them as ≤ and ≥ which probably won't work on all systems, so I don't see how to implement those reliably

It should be plain > or Alt-> (AKA ESC->).

Also, neither Alt-< nor Alt-> are documented on the help screen of less (press h to view it).

They are under ESC, since Alt becomes ESC in the terminal:

       g or < or ESC-<
              Go to line N in the file, default 1 (beginning of file).  (Warning: this may be slow if N is large.)

       G or > or ESC->
              Go to line N in the file, default the end of the file.  (Warning: this may be slow if N is large, or if  N  is
              not specified and standard input, rather than a file, is being read.)

rbutoi avatar Nov 28 '22 16:11 rbutoi

Esc (same as ESC, short for "Escape") it's used for exiting moar (and a lot of other things on different systems), so that's not something I'll be supporting as a prefix.

Alt becomes ESC in the terminal

Just out of curiosity, where did you get this information? In my mind they are totally different things and I don't understand how they could ever "become" each other?

walles avatar Nov 28 '22 17:11 walles

Again, why not do a conf file moar can parse and users can map whatever they like to the keys and you won't be doing stuff that's wasting your time ;-)

On Mon, Nov 28, 2022 at 6:50 PM Johan Walles @.***> wrote:

Esc (same as ESC, short for "Escape") it's used for exiting moar (and a lot of other things on different systems), so that's not something I'll be supporting as a prefix.

Alt becomes ESC in the terminal

Just out of curiosity, where did you get this information? In my mind they are totally different things and I don't understand how they could ever "become" each other?

— Reply to this email directly, view it on GitHub https://github.com/walles/moar/issues/107#issuecomment-1329508847, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL7SAXYS2T62IK62TV4WZ3WKTWHFANCNFSM6AAAAAASFKGH4Q . You are receiving this because you authored the thread.Message ID: @.***>

inoperable avatar Nov 28 '22 19:11 inoperable

Just out of curiosity, where did you get this information? In my mind they are totally different things and I don't understand how they could ever "become" each other?

I gave a handwavy explanation since I'm not too well-versed in it either--it has to to with encoding of keyboard sequences in virtual terminals. ESC is apparently also ^[, see https://wiki.archlinux.org/title/Xterm#Make_'Alt'_key_behave_as_on_other_terminal_emulators.

rbutoi avatar Nov 29 '22 00:11 rbutoi

Again, why not do a conf file moar can parse and users can map whatever they like to the keys and you won't be doing stuff that's wasting your time ;-)

@walles Could you please implement this option? I'm using a non-standard keyboard layout and this would help me out a lot.

Schweber avatar Apr 28 '23 09:04 Schweber

If somebody wants to make a PR for configurable key bindings I'd not be against that, but I won't be implementing this myself.

walles avatar May 01 '23 12:05 walles

So not Vim's "Shift + GG"/gg, but I have noticed that Moar performs identical to Less with "G" going to the bottom. The problem is that "g" doesn't go up to the top like it does in Less. Instead it brings up a "go to line:" bar.

As a drop in replacement shouldn't it follow Less's behavior?

I support the idea of Vim like bindings, but I am not familiar with Go to have a go (heh) at making a PR.

GNOMES avatar Jun 06 '23 21:06 GNOMES