1

I have a problem with Vim Autocompletion behavior for buffer names.

Target Soft/OS

I'm using gVim without plugins on Windows 10

What I would like to do

Assuming we have a file tree like :

+---- a 
+---- b
|     +---- c
|     +---- d
|     +---- e0
|     +---- e
|           +----f
|           +----g

When I'm searching for a buffer name, here is the behavior I would like :

  • :b <Tab> => List a, b/ or every files in the cwd, not all buffers names if possible
  • :b b<Tab> => :b b/
  • :b b/<Tab> => List c, d, e0, e/
  • :b a/e<Tab> => List e0, e/ so I can chose the right path
  • :b a/e/<Tab> => List f/, g/ and so on

What I have tried

set wildmode=longest:list, full

If I want to find the file "Core/types.h", and I have the file "Care/file.h" :

  • :b C<Tab> => it prints every files when I would prefer to have only one level of information, like Core/ and Care/, not Core/types.h and Care/files.h, but this is the less important issue
  • :b Co<Tab> => :b Core/ (This is nice !)
  • :b Core/t<Tab> => does nothing ! (Why it's not taking Core/t as a wildcard ?)
  • :b ty => :b Core/types.h (This is nice !)

Could it be because of the way I'm opening all my buffers ? I'm doing gvim **/* to load all my source files.

Basically the problem is that the autocompletion doesn't work after a directory, as :b ty<Tab> works but not :b Core/ty<Tab>

Hope I was clear and a solution exist for this problem :)

2 Answers 2

3

I believe that :b is only going to select from the buffers you have open. It sounds to me like you want the edit command: :e. That should complete on directories and filenames.

If you are looking for a better way to browse your current open buffers try :ls. It will list all open buffers making it easy to use :b x to go to another. ("x" is a filename or buffer number)

2
  • Exactly ! I want the behavior of the :e edit command, but isn't the edit command opening a new buffer ? Like if I have all my files opened in several different buffers, how can I have the same behavior when I want to switch buffers according to the file name ?
    – Toffanim
    Commented Nov 22, 2016 at 18:16
  • Yes, :e will open a new buffer. :b will only search through your current open buffers. I think you can only tab complete file names with :b. i.e. if you have a buffer named "foo.txt" you can do :b f<Tab> even if you are in a different directory. If you want a better way to see which buffers you have try :ls. This brings up a list of all your open buffers. Then while looking at it you can easily do :b x where "x" is a filename or buffer number.
    – Tumbler41
    Commented Nov 22, 2016 at 18:29
0

This is a bug from vim when using backslash on windows, it can be fixed by using set shellslash

I've reported the bug, but setting shellslash is easy and sufficient enough for everyday use.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.