0

I stumbled on a behaviour which I don't understand. I'm using Bash and Vim 8.2.2434 in Debian 11.

To reproduce it, I created two new files in an empty directory:

foo.py

class Foo:
    def __init__(self, foo):
        self.foo = foo

    def get_foo(self):
        return self.foo

bar.py

import foo

class Bar:
    def __init__(self, bar):
        self.foo = Foo(bar)

    def calc(self):
        return 2 * self.foo.get_foo()

Now I run vim bar.py and place the cursor here:

    def calc(self):                                                            
        return 2 * self.foo.get_foo()
                        ^

Now I execute an external command, in the simplest case one that does nothing:

:!true

Upon the message Press ENTER or type command to continue, I press i.

Now this output appears, it seems to list lines in the two files where the word foo appears, where the cursor is currently on (when doing this with real code, the output may be longer and is paged with -- More -- showing at the bottom):

foo.py
  1:    2     def __init__(self, foo):
  2:    3         self.foo = foo
  3:    6         return self.foo
bar.py
  4:    5         self.foo = Foo(bar)
  5:    8         return 2 * self.foo.get_foo()

After pressing Enter again, I notice that the cursor is now here (it has moved one position to the left):

    def calc(self):                                                            
        return 2 * self.foo.get_foo()
                       ^

To exclude the possibility that any of my Vim settings or plugins have anything to do with it, I close Vim and start it again with vim -u NONE bar.py.

If I now repeat the same steps, the output is a bit different (it doesn't include lines from foo.py anymore, which I hadn't opened, and it adds the line import foo which it didn't show previously):

bar.py
  1:    1 import foo
  2:    5         self.foo = Foo(bar)
  3:    8         return 2 * self.foo.get_foo()

The cursor has still moved one position to the left.

As another experiment, I rename my ~/.vim directory so that Vim can't load my personal settings, but I omit the -u NONE option again.

Now after pressing i it doesn't show any output, but enters insert mode, which is what I would expect from :help press-enter:

-> Press ':' or any other Normal mode command character to start that command.

What is this feature and what does it have to do with running an external command? Why does it occur when using my own Vim settings or none at all, but not when using the default ones?

4
  • 2
    The feature is called "include search" and you can read all abut it under :help include-search. And yes, it has nothing to do with running external commands. What you get is what you would expect after pressing ]I, see :help ]i. FWIW, I can't reproduce your issue with $ vim -u NONE or $ vim --clean in 9.0.1276.
    – romainl
    Commented Feb 28, 2023 at 11:23
  • 1
    @romainl it seems to me that the behavior correspond more to: [I Commented Feb 28, 2023 at 12:51
  • 1
    @VivianDeSmedt You are right. Too late to fix my comment.
    – romainl
    Commented Feb 28, 2023 at 12:56
  • 1
    It seems related to your configuration somehow (like plugins or similar), except that -u NONE replicates the issue (for you; not for others??). You can try How to debug my vimrc, but it may be a weird escape-sequence bug, too.
    – D. Ben Knoble
    Commented Feb 28, 2023 at 16:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.