Use Vim As A Pager
It has been some time since I’ve done a Vim Tip of the Week, but I came across something today that I thought I would share. This tip will allow you to use Vim, with all its syntax highlighting glory, as a pager (similar to
If you use
more regularly to quickly view files, but you’d like to keep the same syntax highlighting that you’d get in Vim you can use an included config that makes Vim act as a pager. Setup the following within your
.bashrc file, or wherever you keep your shell aliases:
alias vless='vim -u /usr/share/vim/vim71/macros/less.vim'
You’ll then need to re-read that file, which can be done using:
At this point you can use
vless to view a file, which will use the beloved syntax highlighting. Normal pager shortcuts should work. q to quit, / to search, pg-up, pg-dn, etc.