Getting a head start on day 2. Short and sweet this time, just one
function and one example.

Let's continue with deleting text, which I find useful for "approving"
changes when processing reports. We use a home-grown tripwire system
for monitoring file changes. Normally I can eyeball these reports, but
occasionally (e.g. after applying a large set of updates) I find it
useful to load the report in vim make use of its functions to so that
I can speed things up. For example, let's imagine that a new kernel
was installed. Using a visual mode is a bit tedious because it is just
inefficient to manually page down to the end of the kernel listings.
Like hitting ".", I can easily overshoot the mark and waste more time
paging up, then down, then up, etc...

In this case, multiple repeats (global commands) come in handy. This
function allows you to search for a pattern and run a command on each
match. Normally the "/" character is used to surround a pattern but
here we have a problem: this is the same character used to separate
directories. It would be a pain to quote each slash! That's okay
because you can use almost any character instead of "/".

Okay, so I want to delete all lines matching
"/lib/modules/2.4.21-58.ELsmp". Here's the command (using "%" instead
of "/"):

:g%/lib/modules/2\.4\.21-58\.ELsmp%d

For more info, launch vim and type:

:help multi-repeat


Chris
P.S. If any programmers would like to jump in and give some
programming tips, feel free to steal a day from me. As a sysadmin, I
don't program very often, but occasionally I do get elbow deep into
Perl scripts and would love to have some time-saving tips.
_______________________________________________
mlug mailing list
[email protected]
https://listes.koumbit.net/cgi-bin/mailman/listinfo/mlug-listserv.mlug.ca

Reply via email to