Friday, October 8, 2010

Automatically add an abbreviation

Hello,

I looked recently at a video of Brian Moolenar, and found that automatically add
an abbreviation would be better and more efficient than open the relevant file
and copy the abbreviation I want.

Currently, I get something which looks like to what I am trying to get, but
don't get it successfully working :

    fun AddAbbr()
        let abb = n2char(getchar('\<LeftMouse>\''\<RightMouse>'))
        let val = input("Par quoi abreger " abb " ? ")
        exec "ia" abb val
        silent call SaveAbbr(abb, val)
    endfun

    fun SaveAbbr(abbr, val)
        redir >>~/.vim/abbr.vim
        echo "iab" a:abbr a:val "\n"
        redir END
    endfun

    map <S-F8> <C-O>:call AddAbbr()<CR>
    vmap <S-F8> <ESC>:call AddAbbr()<CR>


Does anyone know how to do the trick ?

Cheers

--
Alexandre KRISPIN

Web site : my weblog and my repository at Github.


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: