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