Turn vim into a pager/less/more
Little known fact - Vim ships with a script which when invoked turns it into a 'less-like' pager/file viewer.
Benefits?
Syntax highlighting - useful for viewing not only source files, but also configs and logs.
Keybindings!
Here's a function I got in my zshrc (it should also work in bash)
it detects where less.sh is located and invokes it.
# make vim a pager
function vless() {
local less_path=`find $(vim --version | awk ' /fall-back/ { gsub(/\"/,"",$NF); print $NF }' )/ -name less.sh`
if [[ -z $less_path ]]; then
echo 'less.sh not found'
exit 1
fi
$less_path $*
}
Here's a link to my zshrc http://git.io/VU0Q0g
Written by Łukasz Korecki
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#