->
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 less or more).
If you use cat or less or 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:
. .bashrc
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.
If this site has been useful, please consider participating in the Fundraiser.