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:
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
Written by Oliver Mueller
Related protips
2 Responses
yes, \v
is very magic.
over 1 year ago
·
This is awesome!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#