Linux – How to use the vim configuration in less

lesslinuxvim

Quite some programs have commands that output with less(e.g. git blame filename). I would like to use my vim configuration(e.g. <C-j> instead of using Pg Down to go down a page) whenever less is used. How do I set this?

According to this thread and the less man page putting export EDITOR=vim and export VISUAL=vim in my ~/.baschrc should use vim for less but I don't see any change after reloading a terminal session and launching less (I can't use my page down hotkey for example).

Best Answer

The $EDITOR and $VISUAL variables define the editor to use (e.g. when you use the "edit" command inside less).

When programs run less, they run it as a pager, not as an editor – they're looking at the value of $PAGER.

Install vimpager, then:

export PAGER=vimpager
Related Question