Re: References to URIs in email with VIM

Replies:

Parents:

On Tue, Feb 20, 2001, Hugo Haas wrote:
> Gerald once managed to convert me to VIM[1] for email writing, and
> that was definitely a good thing. This editor kicks ass. It's light
> and deleting and adding text in emails is really quick and powerful.
>
> So here is my contribution to the VIM world, and something which is
> going to make my life much easier. When I write emails, I like to put
> URIs at the end because it doesn't obscure the text around it.
> However, I always felt that it was a waste of time to:
> 1) put a number between bracket (that you have to remember).
> 2) go at the bottom of the message.
> 3) insert your URI.
> 4) go back to where you were.
> 5) resume editing.
>
> I have managed to do steps 1 to 4 in two keystrokes.

I have actually rewritten it and I managed to do it in only one key
stroke and it now uses a prompt:
1. In insert mode, press <F5>. (F11 was not convenient)
2. Enter the URI at the "Reference: " prompt.
3. Enter the reference numver at the "Reference number: " prompt (or
just enter, to accept the default).
4. Continue typing stuff.

Press <F6> at the end for cosmetic purposes.

Here is the code:

 function InsertRef()
   let @r = @r + 1
   let ref = input("Reference: ")
   let number = input("Reference number (" . @r . "): ")
   if ( number != "" )
     let @r = number
   endif
   execute "normal a[\<C-R>r]\<ESC>G"
   set paste
   ?^-- $
   execute "normal O  " . @r . ". " . ref . "\<ESC>`rf]"
   set nopaste
   let a = col(".")
   normal $
   let b = col(".")
   if ( a == b )
     startinsert!
   else
     normal `rf]l
     startinsert
   endif
 endfuntion

 map! <F5> <ESC>mr:call InsertRef()<CR>
 map <F6> G?^-- $<CR>O<ESC>

--
Hugo Haas <[email protected]> - http://larve.net/people/hugo/
Me fail English? That's unpossible. -- Ralph Wiggum

Re: References to URIs in email with VIM

Replies:

  • None.

Parents:

I became obsessed with this (mainly because Philippe[3] tried to do a
better one for Emacs) and I ended up doing something that works fine
and I documented it at [1]. The code is at [2].

I removed the empty line before the signature cosmetic fix because it
makes it difficult to continue the editing (well, I had found other
solutions but I am happy with this one).

Do send comments/bugs if you have/find any.

 1. http://larve.net/people/hugo/2001/02/email-uri-refs/
 2. http://larve.net/people/hugo/2001/02/email-uri-refs/uri-ref-20010223.vim
 3. http://www.w3.org/People/LeHegaret/
--
Hugo Haas <[email protected]> - http://larve.net/people/hugo/
I would kill everyone in this room for a drop of sweet beer. -- Homer
J. Simpson

HURL: fogo mailing list archives, maintained by Gerald Oskoboiny