Loading ...
Sorry, an error occurred while loading the content.

Automatically add an abbreviation

Expand Messages
  • Alexandre Krispin
    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
    Message 1 of 2 , Oct 8, 2010
    • 0 Attachment
      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
    • alexandre krispin
      Hello once again, I answer to myself. Actually I was looking at Luc Hermitte s google code page, and I saw this : http://code.google.com/p/lh-vim/wiki/lhVimLib
      Message 2 of 2 , Oct 8, 2010
      • 0 Attachment
        Hello once again,

        I answer to myself.

        Actually I was looking at Luc Hermitte's google code page, and I saw
        this :
        http://code.google.com/p/lh-vim/wiki/lhVimLib
        A library for Vim.

        Then I added his file visual.vim to ~/.vim/autoload/lh/

        And finally, I modified the function previously posted to use it :

        fun AddAbbr()
        normal byw
        let StringChar=lh#visual#selection()
        let val = input("Par quoi abreger " . StringChar . " ? ")
        exec "ia" StringChar val
        silent call SaveAbbr(StringChar, val)
        endfun

        fun SaveAbbr(val, abbr)
        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>

        And it worked perfectly

        Cheers

        On 9 oct, 00:51, Alexandre Krispin <k.m.alexan...@...> wrote:
        > 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
      Your message has been successfully submitted and would be delivered to recipients shortly.