[Gllug] One for the Vim people

Dean Wilson dean.wilson3 at virgin.net
Wed Jan 22 18:07:23 UTC 2003


I've been trying to write a small addin to vim thats started to drive me up
the wall.

My itch: translate long urls to shorter ones (Using
www.makeashorterlink.com) from within vim.
In order to make this easy i thought i'd write a small perl script that was
passed a long url and returned a short one. This is the masl script
attached (Its only a first draft[0])

This turned out to be the easy part. I then went about trying to write the
mappings in vim so that i could just do a single keypress and have it run.
While i've been able to do this:

:map f :read !masl '<cWORD>'<CR>

I wanted to get clever and have it replace the long url with the short one.
This is where its all gone pair shape. I've managed to substitute the
current word for a literal one:

:exe '%s/' . expand('<cWORD>') . '/I_changed/'

But i can't get it to change it to the dynamicly generated word. I've tried
most of the variations around this i can think of:
:exe 's/' . expand('<cWORD>') . '/' . read !masl <cWORD><CR> . '/'

And none of them work. Do i need to up the whole thing to a vim function or
should i go and buy a foot pedel and move to emacs :)

Help!

  Dean
[0] The WWW::MakeAShorterLink module doesn't really give any error
information (just undefs) so its not perfect by a longshot.
--
Profanity is the one language all programmers understand
--- Anon
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: masl.txt
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20030122/9420e113/attachment.txt>


More information about the GLLUG mailing list