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

Words auto completion in Insert mode?

Expand Messages
  • Valery Kondakoff
    Hello, people at vim list! Just downloaded Benji Fisher s word_complete script, that auto-completes the words in Insert mode as they are typed.
    Message 1 of 8 , Mar 31, 2003
      Hello, people at vim list!

      Just downloaded Benji Fisher's 'word_complete' script, that
      auto-completes the words in Insert mode as they are typed.

      Unfortunately, it is impossible to work with this script when
      'ignorecase' is set to 'on': the words are often entered in wrong
      case.

      So, there are my questions - if there are some other auto-completion
      scripts? Is it possible to "adapt" 'word-complete' script to work
      with 'ignorecase'?

      Thank you!

      --
      Best regards,
      Valery Kondakoff
      http://www.nbk.orc.ru (Ne Bey Kopytom)
      http://www.nbk.orc.ru/mtb (MTB riding in Moscow)

      PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...
    • Benji Fisher
      ... In word_complete.vim, find the lines fun! WordComplete() let length=strlen(expand( )) if strlen(getline( . )) == col( . ) || getline( . )[col( . )]
      Message 2 of 8 , Mar 31, 2003
        Valery Kondakoff wrote:
        > Hello, people at vim list!
        >
        > Just downloaded Benji Fisher's 'word_complete' script, that
        > auto-completes the words in Insert mode as they are typed.
        >
        > Unfortunately, it is impossible to work with this script when
        > 'ignorecase' is set to 'on': the words are often entered in wrong
        > case.
        >
        > So, there are my questions - if there are some other auto-completion
        > scripts? Is it possible to "adapt" 'word-complete' script to work
        > with 'ignorecase'?

        In word_complete.vim, find the lines

        fun! WordComplete()
        let length=strlen(expand("<cword>"))
        if strlen(getline(".")) == col(".") || getline(".")[col(".")] =~ '\s'

        and add a few lines to save and reset the 'ignorecase' option:

        let save_ic = &ignorecase
        set noignorecase

        and then, right before the end of the function,

        let &ignorecase = save_ic

        Let me know how well it works.

        HTH --Benji Fisher
      • Valery Kondakoff
        Hello, Benji! ... BF In word_complete.vim, find the lines BF fun! WordComplete() BF let length=strlen(expand( )) BF if
        Message 3 of 8 , Mar 31, 2003
          Hello, Benji!

          Monday, March 31, 2003, you wrote to me:

          >> Is it possible to "adapt" 'word-complete' script to work
          >> with 'ignorecase'?

          BF> In word_complete.vim, find the lines
          BF> fun! WordComplete()
          BF> let length=strlen(expand("<cword>"))
          BF> if strlen(getline(".")) == col(".") || getline(".")[col(".")] =~ '\s'
          BF> and add a few lines to save and reset the 'ignorecase' option:

          BF> let save_ic = &ignorecase
          BF> set noignorecase

          BF> and then, right before the end of the function,

          BF> let &ignorecase = save_ic

          BF> Let me know how well it works.

          Thank you. This works well if you add

          let save_ic = &ignorecase
          set noignorecase

          just in the beginning of the WordComplete (before 'let
          length=strlen(expand("<cword>"))') and the 'let &ignorecase = save_ic'
          just before the end of the function.

          BTW - there is one additional unwanted 'word_complete' side effect:
          this script affects VIM 'undo' function and you need to press 'u'-key
          many times just to undo entering of one or two words.

          As far as I understand there is nothing to be done with this issue?

          Oh... And another one, important issue: your script does not work with
          non-english characters. So, when I switching keymaps autocompletion
          stops working. Are there some workarounds?

          Thank you once again for the help.

          --
          Best regards,
          Valery Kondakoff
          http://www.nbk.orc.ru (Ne Bey Kopytom)
          http://www.nbk.orc.ru/mtb (MTB riding in Moscow)

          PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...

          np: Schneider TM - Turn On* (Zoomer)
        • Benji Fisher
          ... Er, isn t that what I said? ... AFAIK, there is no way to avoid this. It is a side effect of having all those mappings. I thought I had documented this,
          Message 4 of 8 , Mar 31, 2003
            Valery Kondakoff wrote:
            > Hello, Benji!
            >
            > BF> In word_complete.vim, find the lines
            > BF> fun! WordComplete()
            > BF> let length=strlen(expand("<cword>"))
            > BF> if strlen(getline(".")) == col(".") || getline(".")[col(".")] =~ '\s'
            > BF> and add a few lines to save and reset the 'ignorecase' option:
            >
            > BF> let save_ic = &ignorecase
            > BF> set noignorecase
            >
            > BF> and then, right before the end of the function,
            >
            > BF> let &ignorecase = save_ic
            >
            > BF> Let me know how well it works.
            >
            > Thank you. This works well if you add
            >
            > let save_ic = &ignorecase
            > set noignorecase
            >
            > just in the beginning of the WordComplete (before 'let
            > length=strlen(expand("<cword>"))') and the 'let &ignorecase = save_ic'
            > just before the end of the function.

            Er, isn't that what I said?

            > BTW - there is one additional unwanted 'word_complete' side effect:
            > this script affects VIM 'undo' function and you need to press 'u'-key
            > many times just to undo entering of one or two words.
            >
            > As far as I understand there is nothing to be done with this issue?

            AFAIK, there is no way to avoid this. It is a side effect of having all
            those mappings. I thought I had documented this, but it seems I was wrong. I
            just updated the description at

            http://vim.sourceforge.net/scripts/script.php?script_id=73

            to mention this.

            > Oh... And another one, important issue: your script does not work with
            > non-english characters. So, when I switching keymaps autocompletion
            > stops working. Are there some workarounds?

            I'll send you an experimental version off the list.

            > Thank you once again for the help.

            You are welcome. It is nice to know that some people like this feature.

            --Benji Fisher
          • Benji Fisher
            ... Mail that I send to strauss@orc.ru seems to bounce, so I posted the experimental version (0.4) at the usual place:
            Message 5 of 8 , Mar 31, 2003
              Benji Fisher wrote:
              > Valery Kondakoff wrote:
              >
              >> Oh... And another one, important issue: your script does not work with
              >> non-english characters. So, when I switching keymaps autocompletion
              >> stops working. Are there some workarounds?
              >
              >
              > I'll send you an experimental version off the list.

              Mail that I send to strauss@... seems to bounce, so I posted the
              experimental version (0.4) at the usual place:

              http://vim.sourceforge.net/scripts/script.php?script_id=73

              I hope there are no serious bugs!

              --Benji Fisher
            • Valery Kondakoff
              Hello, Benji! ... BF Er, isn t that what I said? Yes, at first I was (mistakenly) thinking, that I need to put two new lines _after_ these lines: let
              Message 6 of 8 , Mar 31, 2003
                Hello, Benji!

                Monday, March 31, 2003, you wrote to me:

                >> BF> In word_complete.vim, find the lines
                >> BF> fun! WordComplete()
                >> BF> let length=strlen(expand("<cword>"))
                >> BF> if strlen(getline(".")) == col(".") || getline(".")[col(".")] =~ '\s'
                >> BF> and add a few lines to save and reset the 'ignorecase' option:
                >>
                >> BF> let save_ic = &ignorecase
                >> BF> set noignorecase
                >>
                BF> Er, isn't that what I said?

                Yes, at first I was (mistakenly) thinking, that I need to put two new
                lines _after_ these lines:

                let length=strlen(expand("<cword>"))
                if strlen(getline(".")) == col(".") || getline(".")[col(".")] =~ '\s'

                So I just wanted to mention - where new lines were finally putted. :)

                >> Oh... And another one, important issue: your script does not work with
                >> non-english characters. So, when I switching keymaps autocompletion
                >> stops working. Are there some workarounds?

                BF> I'll send you an experimental version off the list.

                I'm ready for some testing! :)

                --
                Best regards,
                Valery Kondakoff
                http://www.nbk.orc.ru (Ne Bey Kopytom)
                http://www.nbk.orc.ru/mtb (MTB riding in Moscow)

                PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...

                np: The Cure - Bloodflowers (Bloodflowers) [stopped]
              • Andrew Pimlott
                ... Not having looked at your script, am I correct that this is because every mapping needs to call a function, which requires leaving insert mode? I have
                Message 7 of 8 , Mar 31, 2003
                  On Mon, Mar 31, 2003 at 01:20:53PM -0500, Benji Fisher wrote:
                  > Valery Kondakoff wrote:
                  > >BTW - there is one additional unwanted 'word_complete' side effect:
                  > >this script affects VIM 'undo' function and you need to press 'u'-key
                  > >many times just to undo entering of one or two words.
                  > >
                  > >As far as I understand there is nothing to be done with this issue?
                  >
                  > AFAIK, there is no way to avoid this. It is a side effect of having
                  > all those mappings.

                  Not having looked at your script, am I correct that this is because
                  every mapping needs to call a function, which requires leaving
                  insert mode? I have this problem myself. It would be nice to solve
                  it, as it is (AFAIK) currently impossible to create new insert-mode
                  commands that act like built-ins wrt undo.

                  I can think of two approaches:

                  1. Create a new insert-mode command like i_CTRL-O that does not
                  sync the undo stream.

                  2. Have a new kind of insert mode mapping which evaluates an
                  expression without leaving insert mode, and interprets the
                  result as the right hand side of the mapping. Eg,

                  ifmap a Foo()
                  function Foo()
                  return "abc"
                  endfunction

                  would expand a to abc. This would be a very natural way to
                  implement some features, though I'm not sure it's feasible to
                  evaluate expressions in insert mode.

                  Does this seem roughly on-target?

                  Andrew
                • Benji Fisher
                  ... This may not be possible. I thought, from the docs, that keymaps worked like :lnoremap s, but it seems they do not. I ll post a question to the vim-dev
                  Message 8 of 8 , Apr 1, 2003
                    Valery Kondakoff wrote:
                    > Hello, Benji!
                    >
                    >>>Oh... And another one, important issue: your script does not work with
                    >>>non-english characters. So, when I switching keymaps autocompletion
                    >>>stops working. Are there some workarounds?
                    >>
                    >
                    > BF> I'll send you an experimental version off the list.
                    >
                    > I'm ready for some testing! :)

                    This may not be possible. I thought, from the docs, that keymaps worked
                    like :lnoremap's, but it seems they do not. I'll post a question to the vim-dev
                    list.

                    --Benji Fisher
                  Your message has been successfully submitted and would be delivered to recipients shortly.