Tips for using vim as a log viewer

This probably goes without saying but if you're using log files that are overwritten regularly, then you'll want to:

:set autoread

so vim will keep the latest log up on screen at all times.


What makes it convenient? You've got all the power of vim, of course ... I could recommend the LargeFile plugin, though, such that vim doesn't slow down for large log files.

I use vim to search through large log files, using regexps, and sometimes for specific keywords with *, or sometimes create a copy by selecting only specific lines (e.g. :v//delete), and using block select to get some specific columns in the log output (since log lines mostly follow a specific format). Easiest way to create a quick table, IMHO.


IMO the only thing more you're going to get out of using vim as a pager is syntax highlighting if there is a syntax file for the particular log/file you're viewing. You can try out this sh script which does exactly that:

http://www.vim.org/scripts/script.php?script_id=1723

Although it lacks some of less's built in and useful features such as -F, it's not surprising considering vim was designed to be a text editor not a pager.