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

help needed with completion in version 7

Expand Messages
  • Andrei A. Voropaev
    Hello! There is one thing about completion in version 7 that keeps confusing me. Let s look at the example. Take the text ... int test_func1() { } int
    Message 1 of 12 , Apr 26, 2007
    • 0 Attachment
      Hello!

      There is one thing about completion in version 7 that keeps confusing
      me. Let's look at the example. Take the text

      ------------------------------
      int test_func1()
      {
      }

      int test_func2()
      {
      }
      -----------------------------

      Now I want to add new line

      int test_func3()

      I type 'int t' and the hit CTRL-P. The completion inserts test_func2 for
      me. Now I hit BackSpace and continue typing '3('. But the completion does not
      stop. It contitues untill I hit space. And if before hitting space I
      want to complete another word, then it does not do it for me.

      Is there any way to change this? So that when I hit BackSpace the
      completion stops like it happens when I hit Space? Or even better, stop
      the completion when I do any modification to the text at all?

      Thank you.

      --
      Minds, like parachutes, function best when open
    • A.J.Mechelynck
      ... Completion continues until: - You type a non-word character, such as a space or a comma; - You type a special key which is not used to continue completion;
      Message 2 of 12 , Apr 26, 2007
      • 0 Attachment
        Andrei A. Voropaev wrote:
        > Hello!
        >
        > There is one thing about completion in version 7 that keeps confusing
        > me. Let's look at the example. Take the text
        >
        > ------------------------------
        > int test_func1()
        > {
        > }
        >
        > int test_func2()
        > {
        > }
        > -----------------------------
        >
        > Now I want to add new line
        >
        > int test_func3()
        >
        > I type 'int t' and the hit CTRL-P. The completion inserts test_func2 for
        > me. Now I hit BackSpace and continue typing '3('. But the completion does not
        > stop. It contitues untill I hit space. And if before hitting space I
        > want to complete another word, then it does not do it for me.
        >
        > Is there any way to change this? So that when I hit BackSpace the
        > completion stops like it happens when I hit Space? Or even better, stop
        > the completion when I do any modification to the text at all?
        >
        > Thank you.
        >

        Completion continues until:
        - You type a non-word character, such as a space or a comma;
        - You type a special key which is not used to continue completion;
        - You add a letter for which no completion is found.

        Adding or removing letters at the right makes Vim "recalculate" the set of
        possible completions. I find this very useful if there are too many matches.
        Let's take an example:

        Comment la mort du c<Ctrl-N>

        hoping to find "connestable" (in old French spelling), the next word. However
        there are too many words starting with c or C and the match I need is not
        visible (it's off the first page of menu). gvim completes the first match in
        the menu, maybe C4_11 (an anchor tag name).

        Ctrl-P to go back to what I typed (the menu stays up).
        o (the 2nd letter of the match). Now I see only matches for co-. Depending on
        what I see, I can either type more incremental letters (-n-), or get the
        required word with the proper number of Ctrl-N.

        To abort the menu, use anything which doesn't continue it, or the following
        two commands which specifically exit insert-completion mode:

        <Ctrl-E> to *abort* the completion. The current match is not inserted.
        <Ctrl-Y> to *accept* the completion. The current match is kept and the menu is
        closed.

        These two have no other action than accept or reject the match and close the
        popup (see ":help complete_CTRL-E" and, just below it, ":help complete_CTRL-Y").

        Many other things (including <Esc>) will *accept* the current completion and
        then do what they normally do in Insert mode.


        Best regards,
        Tony.
        --
        Life is a yo-yo, and mankind ties knots in the string.
      • Andrei A. Voropaev
        On Fri, Apr 27, 2007 at 06:51:47AM +0200, A.J.Mechelynck wrote: [...] ... This is not 100% correct. It continues untill space or Enter is encountered. Coma, (
        Message 3 of 12 , Apr 27, 2007
        • 0 Attachment
          On Fri, Apr 27, 2007 at 06:51:47AM +0200, A.J.Mechelynck wrote:
          [...]
          > Completion continues until:
          > - You type a non-word character, such as a space or a comma;

          This is not 100% correct. It continues untill space or Enter is
          encountered. Coma, ( { etc are not counted.

          > - You type a special key which is not used to continue completion;

          Can you please name one such key?

          > - You add a letter for which no completion is found.

          This is incorrect. Even if I type the word that can't be completed, the
          completion stays on. Which I find very strange and inconvinient.

          So, I think the older versions of vim behaved differently here, that is
          why I haven't learned to use the Ctrl-E or Ctrl-Y. And now, with release
          7 I have to adopt new habit of using these.

          --
          Minds, like parachutes, function best when open
        • A.J.Mechelynck
          ... When I type a comma, it closes the popup. Of course, the comma is not included in iskeyword here. If you modify that, the comma will not be recognised as
          Message 4 of 12 , Apr 27, 2007
          • 0 Attachment
            Andrei A. Voropaev wrote:
            > On Fri, Apr 27, 2007 at 06:51:47AM +0200, A.J.Mechelynck wrote:
            > [...]
            >> Completion continues until:
            >> - You type a non-word character, such as a space or a comma;
            >
            > This is not 100% correct. It continues untill space or Enter is
            > encountered. Coma, ( { etc are not counted.

            When I type a comma, it closes the popup. Of course, the comma is not included
            in 'iskeyword' here. If you modify that, the comma will not be recognised as a
            separator, and you'll get menu items with commas in the middle of them if they
            are found in the files Vim uses to find completions.

            >
            >> - You type a special key which is not used to continue completion;
            >
            > Can you please name one such key?

            Sure. <Esc> is one such key: it accepts what has been completed, closes the
            popup, and switches to Normal mode. Then you aren't in completion mode anymore.

            >
            >> - You add a letter for which no completion is found.
            >
            > This is incorrect. Even if I type the word that can't be completed, the
            > completion stays on. Which I find very strange and inconvinient.

            I don't know what you're using, but on my version of Vim and my vimrc it _is_
            correct. (Not that I change much to how completion behaves by default:
            'complete' is at its default of ".,w,b,u,t,i" and "completeopt" is
            "menuone,preview" instead of the default of "menu,preview".) When I add a
            letter after the completion, and there are no matches anymore, the popup
            closes (and what had been completed before the last letter I typed, stays
            there). Very intuitive and very convenient.

            >
            > So, I think the older versions of vim behaved differently here, that is
            > why I haven't learned to use the Ctrl-E or Ctrl-Y. And now, with release
            > 7 I have to adopt new habit of using these.
            >

            Best regards,
            Tony.
            --
            Cold, adj.:
            When the local flashers are handing out written descriptions.
          • Andrei A. Voropaev
            ... Aha, I guess this is where confusion comes. The popup closes, but completion does not stop. At the bottom of screen I still have Keyword completion (^N^P)
            Message 5 of 12 , Apr 27, 2007
            • 0 Attachment
              On Fri, Apr 27, 2007 at 11:00:50AM +0200, A.J.Mechelynck wrote:
              > Andrei A. Voropaev wrote:
              > >On Fri, Apr 27, 2007 at 06:51:47AM +0200, A.J.Mechelynck wrote:
              > >[...]
              > >>Completion continues until:
              > >>- You type a non-word character, such as a space or a comma;
              > >
              > >This is not 100% correct. It continues untill space or Enter is
              > >encountered. Coma, ( { etc are not counted.
              >
              > When I type a comma, it closes the popup. Of course, the comma is not

              Aha, I guess this is where confusion comes. The popup closes, but
              completion does not stop. At the bottom of screen I still have "Keyword
              completion (^N^P) match 1 of 2". And this does not go away untill I hit
              Space, Enter, Esc, Ctrl-Y, Ctrl-E. The funniest thing is, that even
              after I've added ( or , to the text and popup is gone, the message still
              says "1 match of 2" :)


              > I don't know what you're using, but on my version of Vim and my vimrc it
              > _is_ correct. (Not that I change much to how completion behaves by default:
              > 'complete' is at its default of ".,w,b,u,t,i" and "completeopt" is
              > "menuone,preview" instead of the default of "menu,preview".) When I add a
              > letter after the completion, and there are no matches anymore, the popup
              > closes (and what had been completed before the last letter I typed, stays
              > there). Very intuitive and very convenient.

              Yep. I have the same settings. And the same behaviour up to the point
              that completion does not stop after the popup is gone. Only this I find
              inconvinient. If there are no more matches to the text, the completion
              must stop and not just hide the popup.

              --
              Minds, like parachutes, function best when open
            • A.J.Mechelynck
              ... Ah, finally, I can reproduce that. I think it s only a missing screen redraw. If I backspace, then type a few letters, then (let s say) a period, the
              Message 6 of 12 , Apr 27, 2007
              • 0 Attachment
                Andrei A. Voropaev wrote:
                > On Fri, Apr 27, 2007 at 11:51:52AM +0200, Andrei A. Voropaev wrote:
                >> On Fri, Apr 27, 2007 at 11:00:50AM +0200, A.J.Mechelynck wrote:
                >>> Andrei A. Voropaev wrote:
                >>>> On Fri, Apr 27, 2007 at 06:51:47AM +0200, A.J.Mechelynck wrote:
                >>>> [...]
                >>>>> Completion continues until:
                >>>>> - You type a non-word character, such as a space or a comma;
                >>>> This is not 100% correct. It continues untill space or Enter is
                >>>> encountered. Coma, ( { etc are not counted.
                >>> When I type a comma, it closes the popup. Of course, the comma is not
                >> Aha, I guess this is where confusion comes. The popup closes, but
                >> completion does not stop. At the bottom of screen I still have "Keyword
                >> completion (^N^P) match 1 of 2". And this does not go away untill I hit
                >> Space, Enter, Esc, Ctrl-Y, Ctrl-E. The funniest thing is, that even
                >> after I've added ( or , to the text and popup is gone, the message still
                >> says "1 match of 2" :)
                >
                > Aha, I think, that here we talk about a bug! If I hit Ctrl-N, get the
                > needed completion, and then start typing further, then the completion
                > stops as soon as there are no more matches. BUT. If after Ctrl-N I hit
                > Backspace first, and then continue typing, then completion does not stop
                > even when there are no more matches. In this case only Esc or Ctrl-Y
                > aborts the completion.
                >

                Ah, finally, I can reproduce that. I think it's only a missing screen redraw.
                If I backspace, then type a few letters, then (let's say) a period, the
                message "match m of n" is still there. Hitting <Left> makes it disappear
                (replaced by "-- INSERT --"), after which <Right> brings the cursor back where
                it belongs.


                Best regards,
                Tony.
                --
                hundred-and-one symptoms of being an internet addict:
                204. You're being audited because you mailed your tax return to the IRC.
              • A.J.Mechelynck
                ... Hm, that kind of error was mentioned in another thread that s still active. The OP in question says that his sysadmin just installed the latest Debian
                Message 7 of 12 , Apr 27, 2007
                • 0 Attachment
                  Andrei A. Voropaev wrote:
                  > On Fri, Apr 27, 2007 at 01:17:39PM +0200, A.J.Mechelynck wrote:
                  > [...]
                  >>> Aha, I think, that here we talk about a bug! If I hit Ctrl-N, get the
                  >>> needed completion, and then start typing further, then the completion
                  >>> stops as soon as there are no more matches. BUT. If after Ctrl-N I hit
                  >>> Backspace first, and then continue typing, then completion does not stop
                  >>> even when there are no more matches. In this case only Esc or Ctrl-Y
                  >>> aborts the completion.
                  >>>
                  >> Ah, finally, I can reproduce that. I think it's only a missing screen
                  >> redraw. If I backspace, then type a few letters, then (let's say) a period,
                  >> the message "match m of n" is still there. Hitting <Left> makes it
                  >> disappear (replaced by "-- INSERT --"), after which <Right> brings the
                  >> cursor back where it belongs.
                  >
                  > Unfortunately it's not just a missing screen. If you try to do
                  > completion again it won't work. So again, type the beginning of word,
                  > hit Ctrl-N, hit Backspace, type ( and beginning of another word, hit
                  > Ctrl-N to complete it. It won't work saying that there are no matches.
                  > That's because old completion is still active and it tries to complete
                  > the whole thing. This happens very often when one has to write C
                  > functions :) So, I would say this is a more serious bug than just
                  > missing update of the screen.
                  >
                  > Actually, I've hit another bug few times already, unfortunately I can't
                  > reproduce it. When I type quickly and miss a key, then I try to undo my
                  > changes and instead get back the message "Can't undo, the line numbers
                  > are incorrect" or something like that. Usually it happens after I hit
                  > 2-3 keys wrong, so I still can't reproduce it. Well, when I type
                  > japanese text in "over the spot" mode this is "normal". But everyone
                  > decided that this is a bug in the japanese input. Looks like it can be
                  > triggered also in non-japanes input.
                  >

                  Hm, that kind of error was mentioned in another thread that's still active.
                  The OP in question says that his sysadmin just installed the latest Debian
                  distro, including a Vim 7.0.122 which doesn't include some bugfix that may be
                  critical to cure that undo problem. You may want to compile the latest Vim
                  (7.0.233, several patches published yesterday). It won't help with that popup
                  problem (which I can now reproduce with the latest build) but it may help with
                  your undo problem.


                  Best regards,
                  Tony.
                  --
                  Cocaine is nature's way of telling you you have too much money.
                • A.J.Mechelynck
                  ... The way I do it is to fetch the patches separately by FTP and apply all _new_ patches in ascending order. There are collected patches for 001-100 and
                  Message 8 of 12 , Apr 27, 2007
                  • 0 Attachment
                    Andrei A. Voropaev wrote:
                    > On Fri, Apr 27, 2007 at 03:30:45PM +0200, A.J.Mechelynck wrote:
                    >> Andrei A. Voropaev wrote:
                    >>> Actually, I've hit another bug few times already, unfortunately I can't
                    >>> reproduce it. When I type quickly and miss a key, then I try to undo my
                    >>> changes and instead get back the message "Can't undo, the line numbers
                    >>> are incorrect" or something like that. Usually it happens after I hit
                    >> You may want to compile the latest
                    >> Vim (7.0.233, several patches published yesterday). It won't help with that
                    >> popup problem (which I can now reproduce with the latest build) but it may
                    >> help with your undo problem.
                    >
                    > Oh, that's right, I haven't updated my version for a long time now :)
                    > Do I understand it correctly, that sources are not patched, so I have to
                    > get all of the patches separately and apply them?
                    >

                    The way I do it is to fetch the patches separately by FTP and apply all _new_
                    patches in ascending order. There are collected patches for 001-100 and
                    101-200. I suppose that a new collection will be published if and when 7.0.300
                    is reached.

                    The alternative is to maintain the sources by CVS or SVN (or AAP, which
                    requires Python). Since I don't use it, I don't know which URLs to apply. What
                    I do know is that CVS usually lags by a day or two after FTP, and SVN may lag
                    by a week or two after CVS.

                    You may see how I compile Vim by browsing to my home site:
                    (Win32) http://users.skynet.be/antoine.mechelynck/vim/compile.htm
                    (Linux) http://users.skynet.be/antoine.mechelynck/vim/compunix.htm

                    Best regards,
                    Tony.
                    --
                    Maybe you can't buy happiness, but these days you can certainly charge
                    it.
                  • Bram Moolenaar
                    ... When you press Backspace you go into a mode where you edit the text, so that you can change the list of matches. Just about any character can appear in
                    Message 9 of 12 , Apr 27, 2007
                    • 0 Attachment
                      Andrei Voropaev wrote:

                      > On Fri, Apr 27, 2007 at 01:17:39PM +0200, A.J.Mechelynck wrote:
                      > [...]
                      > > >Aha, I think, that here we talk about a bug! If I hit Ctrl-N, get the
                      > > >needed completion, and then start typing further, then the completion
                      > > >stops as soon as there are no more matches. BUT. If after Ctrl-N I hit
                      > > >Backspace first, and then continue typing, then completion does not stop
                      > > >even when there are no more matches. In this case only Esc or Ctrl-Y
                      > > >aborts the completion.
                      > > >
                      > >
                      > > Ah, finally, I can reproduce that. I think it's only a missing screen
                      > > redraw. If I backspace, then type a few letters, then (let's say) a period,
                      > > the message "match m of n" is still there. Hitting <Left> makes it
                      > > disappear (replaced by "-- INSERT --"), after which <Right> brings the
                      > > cursor back where it belongs.
                      >
                      > Unfortunately it's not just a missing screen. If you try to do
                      > completion again it won't work. So again, type the beginning of word,
                      > hit Ctrl-N, hit Backspace, type ( and beginning of another word, hit
                      > Ctrl-N to complete it. It won't work saying that there are no matches.
                      > That's because old completion is still active and it tries to complete
                      > the whole thing. This happens very often when one has to write C
                      > functions :) So, I would say this is a more serious bug than just
                      > missing update of the screen.

                      When you press Backspace you go into a mode where you edit the text, so
                      that you can change the list of matches. Just about any character can
                      appear in the matches (e.g., for line completion or when using omni
                      completion). It's difficult to decide when to leave this editing mode.
                      Also because you can make a typo, and expect Backspace to correct that.
                      If the key exits completion mode you can't go back to what you were doing.

                      > Actually, I've hit another bug few times already, unfortunately I can't
                      > reproduce it. When I type quickly and miss a key, then I try to undo my
                      > changes and instead get back the message "Can't undo, the line numbers
                      > are incorrect" or something like that. Usually it happens after I hit
                      > 2-3 keys wrong, so I still can't reproduce it. Well, when I type
                      > japanese text in "over the spot" mode this is "normal". But everyone
                      > decided that this is a bug in the japanese input. Looks like it can be
                      > triggered also in non-japanes input.

                      If you find a way to reproduce this "undo line numbers wrong error" then
                      I would very much like to see it. It's hard to fix something that I
                      can't reproduce.

                      --
                      How To Keep A Healthy Level Of Insanity:
                      5. Put decaf in the coffee maker for 3 weeks. Once everyone has gotten
                      over their caffeine addictions, switch to expresso.

                      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                      \\\ download, build and distribute -- http://www.A-A-P.org ///
                      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
                    • Andrei A. Voropaev
                      ... [...] ... Aha, this is a feature after all. Is this something new for Version 7? I don t remember such behaviour in the old version. I guess there s no way
                      Message 10 of 12 , Apr 30, 2007
                      • 0 Attachment
                        On Fri, Apr 27, 2007 at 11:23:06PM +0200, Bram Moolenaar wrote:
                        > Andrei Voropaev wrote:
                        [...]
                        > > Unfortunately it's not just a missing screen. If you try to do
                        > > completion again it won't work. So again, type the beginning of word,
                        > > hit Ctrl-N, hit Backspace, type ( and beginning of another word, hit
                        > > Ctrl-N to complete it. It won't work saying that there are no matches.
                        > > That's because old completion is still active and it tries to complete
                        > > the whole thing. This happens very often when one has to write C
                        > > functions :) So, I would say this is a more serious bug than just
                        > > missing update of the screen.
                        >
                        > When you press Backspace you go into a mode where you edit the text, so
                        > that you can change the list of matches.

                        Aha, this is a feature after all. Is this something new for Version 7? I
                        don't remember such behaviour in the old version. I guess there's no way
                        to turn this feature off, since it is very confusing for me. I feel it
                        is much easier to hit Ctrl-N one more time after I've done my
                        adjustments, than to remember, that any adjustment I start will result
                        in almost endless completion.

                        In fact it is still broken. Let's look at example. I have word "brown"
                        in text. Now I type "bru" and hit Ctrl-N. Completion says "No matches".
                        I think "oops, typo", hit BackSpace, Oops. Completion has ended :)

                        So, this appears to be the feature that works where it shouldn't, but
                        does not work where it should :)

                        > It's difficult to decide when to leave this editing mode.
                        > Also because you can make a typo, and expect Backspace to correct that.
                        > If the key exits completion mode you can't go back to what you were doing.

                        It's strange that you are saying "it's difficult to decide when to leave
                        the editing mode". As soon as there are no matches after my editing, the
                        completion shall stop, just like it stops when I don't hit the BackSpace
                        key. Or do I miss something? I mean, why appending to what I've typed is
                        different from modifying it? Essentially it's just different way to
                        modify the input for the completion function. From my naive point of
                        view, the logic should be something like following.

                        User starts completion of a word. Display available matches if any,
                        wait for input. More text provided, leave the completion as
                        soon as text does not match anything. Text is reduced using BackSpace,
                        then adjust the matches, return to waiting for input or stop completion,
                        if the user deleted the word completely.


                        > If you find a way to reproduce this "undo line numbers wrong error" then
                        > I would very much like to see it. It's hard to fix something that I
                        > can't reproduce.

                        Yes, I know :) I'll keep looking. Hopefully this was already fixed by
                        the patches. I was missing about 150 of them :)

                        Andrei
                      • Bram Moolenaar
                        Andrei Voropaev wrote: [...] ... When you have 500 matches you can type some more characters to reduce the number of matches. But you may make a typo and end
                        Message 11 of 12 , Apr 30, 2007
                        • 0 Attachment
                          Andrei Voropaev wrote:
                          [...]
                          > > It's difficult to decide when to leave this editing mode.
                          > > Also because you can make a typo, and expect Backspace to correct that.
                          > > If the key exits completion mode you can't go back to what you were doing.
                          >
                          > It's strange that you are saying "it's difficult to decide when to leave
                          > the editing mode". As soon as there are no matches after my editing, the
                          > completion shall stop, just like it stops when I don't hit the BackSpace
                          > key. Or do I miss something? I mean, why appending to what I've typed is
                          > different from modifying it? Essentially it's just different way to
                          > modify the input for the completion function. From my naive point of
                          > view, the logic should be something like following.

                          When you have 500 matches you can type some more characters to reduce
                          the number of matches. But you may make a typo and end up with zero
                          matches. Then it's nice you can press backspace and type the right
                          character. Otherwise you would have to start completion again (e.g.,
                          with CTRL-X CTRL-O when you were doing omni completion).

                          --
                          hundred-and-one symptoms of being an internet addict:
                          34. You laugh at people with 14400 baud modems.

                          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                          \\\ download, build and distribute -- http://www.A-A-P.org ///
                          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
                        • Andrei A. Voropaev
                          ... Well, that would be nice. But it does not work this way now :) If I have 500 matches and hit a key that turns my word into no-match , then the completion
                          Message 12 of 12 , May 1, 2007
                          • 0 Attachment
                            On Mon, Apr 30, 2007 at 10:36:18PM +0200, Bram Moolenaar wrote:
                            > When you have 500 matches you can type some more characters to reduce
                            > the number of matches. But you may make a typo and end up with zero
                            > matches. Then it's nice you can press backspace and type the right
                            > character. Otherwise you would have to start completion again (e.g.,
                            > with CTRL-X CTRL-O when you were doing omni completion).

                            Well, that would be nice. But it does not work this way now :) If I have
                            500 matches and hit a key that turns my word into "no-match", then the
                            completion aborts. So, either way something has to be changed. It is no
                            good when after BackSpace the completion continues, but after a typo it
                            aborts. It just contradicts itself. I don't need to hit BackSpace untill
                            I make typo, but when I make typo it's too late already :)

                            Still, this way will require learning new habbit of using Ctrl-Y to end
                            completion, because otherwise the completion won't end. I think it is
                            safer to abort completion as soon as there's no match :)

                            --
                            Minds, like parachutes, function best when open
                          Your message has been successfully submitted and would be delivered to recipients shortly.