While viewing text in less
, you can press v
to view the text in $VISUAL
or $EDITOR
. If you want to change the keys for less
, you can use lesskey
. But, it's not available on OS X without compiling less
yourself or installing it from homebrew.
As pointed out in the question's comments, there are plugins and environment variables that can change the pager program. However, I mainly wanted to answer this question to point something out to new users who are enthusiastic about having Vim all over the place: You really don't want Vim to be your pager.
You want your pager to be fast, and less
is fast at displaying text. It's fast because it only loads as many lines as there are in your terminal session. You can open up a giant text file with less and it will appear instantly in most cases. You're not going to be able to jump to the bottom of a 20GB text file with less
, but you'll at least be able to briefly regret the decision and quit quickly.
Compared to less
, Vim is not fast. Vim loads the entire text into memory. If you're unlucky, Vim will also find a matching syntax file for what's loaded and you'll be stuck waiting for the text to be highlighted. On top of that, you might hit the wrong keys and cause Vim to re-indent a giant text file. Optimistically, you'll be waiting a minute, but most likely, the process will have to be killed. Sure, you can make Vim run in read-only mode, but that only keeps you from saving the file. Vim can still do things very slowly to the text that's loaded.
Vim is a great text editor, but it's not good for all text-related activities.
less
to use yourvimrc
?