Back to Top

Tuesday, September 13, 2011

Using less with syntax highlight

You can use vim as your pager and obtain two benefits: syntax highlight and access to all the advanced commands (like search). You can do this under ubuntu by adding the following line to your ~/.bashrc:

alias less='/usr/share/vim/vimcurrent/macros/'


  • You have to have vim installed (which doesn't come by default, but it is as simple as sudo apt-get install vim-nox)
  • It supports viewing directly bz2 and gz archives as well as pipe input from stdin (but in that case it fails sometime to highlight)
  • Edit commands (like dd) are disabled, so you can't accidentally modify the file you are viewing


Post a Comment

You can use some HTML tags, such as <b>, <i>, <a>. Comments are moderated, so there will be a delay until the comment appears. However if you comment, I follow.