On Mon, Jul 16, 2001 at 03:41:01PM -0700, Paul Mackinney wrote: | D-Man uttered: | > | > [I haven't been following most of this thread, but] | > | > On Mon, Jul 16, 2001 at 10:59:23AM -0700, Paul Mackinney wrote: | > | Night before last I ran 'find /usr/doc -name "index.html" >foo.txt' and | > | then spent 2 hours adding links from foo.txt to my local home/start | > | > 2 hours!? Wow. Learn vi(m) or some other advanced editor. If you | > have that foo.txt with each filename on its own line the following | > will take very little time to create a web page of links out of it. | | Vim is indeed my editor of choice. The 2 hours was mostly because I got | distracted reading & checking out the stuff I found. But my edits
Oh, ok. That's better. Two hours reading docs, not two hours creating HTML links. (BTW, thanks guys for those other generation techniques) | weren't nearly as slick as what you suggest. | | Thanks to a conversation at a BAD (Bay Area Debian) meeting last week, I | was clued in to visual mode. Here's what I did: | 1. At the first line, type 'v' to enter visual mode. | 2. Scroll to the last line, type ':' | 3. Vim starts the command text for you. Append | s/^/<a href="file:\/\//g <enter> | | 4. Repeat the command, this time appending | s/$/\"> DESCR <\/a>/g | | This turned a line like | /usr/share/doc/apache/manual/mod/index.html | | into | <a href="file:///usr/share/doc/apache/manual/mod/index.html"> DESCR </a> Yes, visual mode is great when you want to operate on a subset of the buffer. The '%' at the beginning of my command means use the whole buffer. | But your technique for capturing the original line & using it for the | link description is very cool & will save me much effort for my updates. Thanks. Actually, I'm not 100% sure that vim supports backreferences like that (the \1 in the replacement text). I know that Python's and Perl's regex engines do. I think I've heard/read that vim does do backreferences. BTW, I probably spent more time making my sample commands a little shorter than you spent with your slightly simpler version. Also, the simpler the command is the more likely it is correct ;-). -D