VIM as a syntax highlighting pager

Éverton Arruda

I’ve been looking for a way to use less with syntax highlight and ended up in a page of Ubuntu Tutorials[0] website with a very good tip: Using VIM as a syntax highlighting pager[1].

All you’ll need is the package vim-full, só, in Debian-like systems, you’ll need to execute:

1
# aptitude install vim-full

Then, you’ll have to execute:

1
$ vim -u /usr/share/vim/vim72/macros/less.vim <FILE>

And you have it working!
NOTE: Depending on the version of your VIM, the path to less.vim might be different.

You can make this command simpler by creating an alias and adding it to your .bashrc file:

1
$ echo "alias vless=\"vim -u /usr/share/vim/vim72/macros/less.vim\"" >> ~/.bashrc

Now the system will need to re-read your .bashrc file, so the changes may be applied:

1
$ . ~/.bashrc

And after this you can test vless:

1
$ vless <FILE>

[0] http://ubuntu-tutorials.com
[1] http://ubuntu-tutorials.com/2008/07/14/use-vim-as-a-syntax-highlighting-pager/

:wq


Leave a Reply