Last Updated: February 08, 2017
·
2.82K
· coldgrnd

VIM as a log viewer/logfile filter

searching huge logfiles can easily be done in VIM.
even filtering for specific keywords is easy using the global command in it's inverse form:

*:v* *:vglobal*
:[range]v[global]/{pattern}/[cmd]
        Same as :g!.

filtering a 100.000 line logfile is almost instant, e.g.

:v/\v(TIME UPDATED)/d

but most of the time it's necessary to filter for multiple patterns. No problem, just specify multiple patterns in your search:

:v/\v(TIME UPDATED)|(ntp)|(SHUTDOWN)/d

this will even mark every found pattern:

Picture

by the way, the \v stands for "very magic" and allows you to avoid escaping special characters such as braces:
Use of "\v" means that in the pattern after it all ASCII characters except
'0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning. "very magic"

if syntax-highlighting slows you down just turn it of:

:syntax off

2 Responses
Add your response

yes, \v is very magic.

over 1 year ago ·

This is awesome!

over 1 year ago ·