Is there a way to get Vim-style modal editing in a Linux pager?

I’d like to be able to navigate text in a pager with Vim-style modal editing (moving with hjkl and yank/paste with y/p). Is there a way to enable this in the default pager, or is there an alternative pager that supports this kind of modal behavior?

19 points · 5 comments · view on lemmy.world

5 Comments

thingsiplay@beehaw.org · 17 pts · 281d (2 replies)

You can set Vim as your pager. If you are on Neovim, its very easy, just set this variable:

export PAGER='nvim +Man!'
export MANPAGER="${PAGER}"

Then try man grep. These variables could be set in your .bashrc in example. If you use the "original" Vim, it's a bit more complicated to setup. I did that before too, so it's definitely doable.

SinTan1729@programming.dev · 4 pts · 280d

This, but I use bat since it seems to be faster for this.

Edit: I should clarify that I only use bat as the MANPAGER, since bat uses less under the hood for paging anyway. But with support for a built-in pager in the new release, perhaps it makes sense to set it as the PAGER too.

Fizz@lemmy.nz · 1 pts · 280d

What's the Wayland equiv? I did a quick search and got a few different answers. Apparently bashrc still works since its your term shell but not for setting variables in the login shell. One comment said it could be ~/.profile

Do you know?

whimsy@lemmy.zip · 16 pts · 281d

I'm a bit confused by your question. less is usually the default pager and it supports vim style navigation out of the box. Moreover, a pager is just for viewing content (historically which didn't fit on the screen), and not for editing. So I'm not sure what you mean by pasting

rc__buggy@sh.itjust.works · 3 pts · 281d

I'm on my phone, but when using less "v" opens the file in $EDITOR. I don't remember if it defaults to read only