Sven Guckes ©1995-2001 | Last update: Sat Nov 17 02:40:00 MET 2001 |
Here's how it works: Put all your signatures into one file, say, $HOME/.Signatures. [NOTE: *Dont* use the filename $HOME/.signature as this is the default filename that many programs use for the signature. This could simply lead to some confusion.] Separate signatures with "sigdashes" (you know, dash-dash-space ;-). Example:
-- Sven Guckes sig-mutt @guckes.net using mutt-1.2.5 [000729] ,, MUTT http://www.mutt.org/ news:comp.mail.mutt (__/'. MUTT http://www.guckes.net/mutt/ -> sample setup files /| |\ MUTT MUTT - *the* mailer for UNIX with color, threading, IMAP+MIME+PGP+POP -- Sven Guckes guckes@vim.org [vim-version] VIM VERSION latest user release: VIM-5.7 [000624] VIM VERSION latest user release patch: VIM-5.7.26 [010309] VIM VERSION latest developer release: VIM-6.0z [010325]And from within Vim you use the ":read" command to read in the putput of the "agrep" command. To understand how this works try the command :r!date which reads in the current date and time of your machine after the current line.
Let's try agrep on the shell first: Use option "-d" which tells agrep that the next "word" is the pattern that describes the "delimiter". Patterns (aka "regular expressions") are a poweful way of describing sets of strings with "meta characters".
A '^' ("caret") denotes the start-of-line, and a '$' ("dollar") denotes the end-of-line. Therefore a line that contains only dash-dash-space is described with ^-- $.
Now try this command on your ".Signatures" file:
$ agrep -d "^-- $" muttsig $HOME/.Signatures -- Sven Guckes sig-mutt @guckes.net using mutt-1.2.5 [000729] ,, MUTT http://www.mutt.org/ news:comp.mail.mutt (__/'. MUTT http://www.guckes.net/mutt/ -> sample setup files /| |\ MUTT MUTT - *the* mailer for UNIX with color, threading, IMAP+MIME+PGP+POPAs you can see, agrep has now extracted the lines between two sigdashes lines which contains the word "muttsig". Please note that the first delimiter (sigdashes) are also in the output. No need to add sigdashes. :-)
Now all you need to know is that the Vi command :read can not only read in the contents of some file but also the output of a command:
:read !agrep -d "^-- $" keyword $HOME/.SignaturesMind you, this is a standard Vi feature. No special improvement by Vim here.
So here it is: The mapping that will put this command onto your command line, including the cursor movements which palces the cursor right at the position to type in the keyword for your special signature:
Enjoy! :-)
-v print only non-matching items -d next parameter gives delimiter ^$ an empty line (start followed directly by end) Windows to be eliminated!
S. Wu and U. Manber Agrep: A Fast Approximate Pattern-Matching Tool @inproceedings{Wu:91, AUTHOR = {S. Wu and U. Manber}, TITLE = {Agrep: A Fast Approximate Pattern-Matching Tool}, YEAR = 1991, BOOKTITLE = {Proc.\ of the Winter 1992 USENIX Conference}, ADDRESS = {San Francisco, California}, PAGES = {153-162}, KEYWORDS = {}}
URL: http://www.guckes.net/agrep/ Created: Fri Jun 20 00:00:00 CEST 1997Send feedback on this page to