browser icon
You are using an insecure version of your web browser. Please update your browser!
Using an outdated browser makes your computer unsafe. For a safer, faster, more enjoyable user experience, please update your browser today or try a newer browser.

‘less’ with code syntax highlighting!

Posted by on March 2, 2016

If you’ve installed a reasonably up-to-date version of vi(m), there is a script called in your $VIMRUNTIME directory, which acts as an replacement of less providing syntax highlighting.

To use this script, you just have to follow these simple steps:

For the lazy like me:

  • sudo ln -s `ls /usr/share/vim/vim*/macros/ | tail -n 1` /usr/bin/vless

For the diligent:

  • Launch vi and type :echo $VIMRUNTIME.
    This shows you the path to the vi files.
    On my Ubuntu box this is /usr/share/vim/vim74.
  • Now create the symlink: sudo ln -s /usr/share/vim/vim74/macros/ /usr/bin/vless.
    If you’ve got another path before, you have to edit this command appropriately.
  • That’s all. Now vless acts fairly similar to less with paging and now with syntax highlighting: vless

Of course, vless can also be used within shell pipes:

  • wget -qO- | vless

Props to this guy!

Comments are closed.