Last Updated: February 25, 2016
· lukaszkorecki

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.


Syntax highlighting - useful for viewing not only source files, but also configs and logs.


Here's a function I got in my zshrc (it should also work in bash)
it detects where 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`
  if [[ -z $less_path ]]; then                                               
    echo ' not found'                                                 
    exit 1                                                                   
  $less_path $*                                                              


Here's a link to my zshrc