2

When jumping between buffers in Vim, most the time things work quite smoothly.

I like to jump to buffers by writing :b something1*something2, checking if the match is unique by invoking C-d, and if so executing the command. However, for certain files, Vim gives E93: More than one match despite C-d giving only one result.

Why is this so, and how can I fix it?

Edit:

As noted in the comments, I myself don't always run into the issue; clearly this issue is not "supposed" to happen and is not triggered on typical cases, making it non-trivial to reproduce...

Finally, I've run into the issue again and managed to produce a file structure that appears to demonstrate the issue.

First, create this file tree in the shell:

mkdir test-vim-1
cd test-vim-1

mkdir -p src/app/jargon/views/
mkdir -p src/app/jargon/views/ProfileEditBottomSheetView/
mkdir -p src/app/jargon/views/ProfileEditBottomSheetView/
mkdir -p src/app/jargon/views/CheckInBottomSheetView/
mkdir -p src/app/jargon/views/pages/my-account/
mkdir -p src/app/jargon/views/ProfileEditBottomSheetView/
mkdir -p src/app/jargon/views/pages/home/
mkdir -p src/app/jargon/views/LanguagesBottomSheetView/
mkdir -p src/app/jargon/views/pages/coffee-house-detail/
mkdir -p src/app/jargon/views/
mkdir -p src/app/jargon/views/pages/chat/
mkdir -p src/app/jargon/views/pages/coffee-house-detail/
touch src/app/jargon/views/ShareWithFriendsBottomSheetView.js 
touch src/app/jargon/views/ProfileEditBottomSheetView/ProfileEditBottomSheetView.js 
touch src/app/jargon/views/ProfileEditBottomSheetView/ProfileImageControl.js 
touch src/app/jargon/views/CheckInBottomSheetView/CheckInBottomSheetView.js 
touch src/app/jargon/views/pages/my-account/OptionsMenuBottomSheetView.js 
touch src/app/jargon/views/ProfileEditBottomSheetView/profile-edit-bottom-sheet-view-terms.js 
touch src/app/jargon/views/pages/home/CoffeeHouseSearchBottomSheetView.js 
touch src/app/jargon/views/LanguagesBottomSheetView/LanguagesBottomSheetView.js 
touch src/app/jargon/views/pages/coffee-house-detail/ViewMemberBottomSheetView.js 
touch src/app/jargon/views/BottomSheetLayout.js 
touch src/app/jargon/views/pages/chat/AllReactionsBottomSheetView.js 
touch src/app/jargon/views/pages/coffee-house-detail/AddAdminBottomSheetView.js

Now, open vim, and open all the files (replace with your $PWD or test-vim-1):

:e /<path-to-dir>/src/app/jargon/views/ShareWithFriendsBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/ProfileEditBottomSheetView/ProfileEditBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/ProfileEditBottomSheetView/ProfileImageControl.js | e /<path-to-dir>/src/app/jargon/views/CheckInBottomSheetView/CheckInBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/pages/my-account/OptionsMenuBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/ProfileEditBottomSheetView/profile-edit-bottom-sheet-view-terms.js | e /<path-to-dir>/src/app/jargon/views/pages/home/CoffeeHouseSearchBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/LanguagesBottomSheetView/LanguagesBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/pages/coffee-house-detail/ViewMemberBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/BottomSheetLayout.js | e /<path-to-dir>/src/app/jargon/views/pages/chat/AllReactionsBottomSheetView.js | e /<path-to-dir>/src/app/jargon/views/pages/coffee-house-detail/AddAdminBottomSheetView.js

Finally, now type : b Bot, and <C-d> will somehow only produce src/app/jargon/views/BottomSheetLayout.js even though every other buffer contains the substring "Bot", and pressing Enter will produce the stated error.

(:version tells us that my vim is "VIM - Vi IMproved 9.0", "Included patches: 1-1441")

14
  • What version of Vim?
    – Heptite
    Sep 9, 2023 at 15:11
  • :version reports VIM - Vi IMproved 9.0 (2022 Jun 28) Included patches: 1-1441 Sep 9, 2023 at 15:44
  • This seems like a bug of some sort. Do you have any plugins running?
    – Heptite
    Sep 9, 2023 at 16:09
  • No, I haven't got any. Any suggestions find the issue? I notice that sometimes this occurs when another buffer with a similar name is in my loaded buffers. However, given that <C-d> only returns one match, I'm not sure what's going on. Sep 9, 2023 at 16:36
  • Have you tried moving your vimrc aside temporarily?
    – Heptite
    Sep 9, 2023 at 18:56

1 Answer 1

0

It turns out, this is a bug (or should I say feature?), that the buffer completion code always favors patterns matching beginning of line or being anchored to directory separators and if it finds matches for such buffers, does not consider to try to match the pattern elsewhere in the buffer name.

I have now fixed this with Vim patch 9.1.0131, read the commit message discussing this feature/bug.

1
  • I've replied in the issue - I don't think your explanation about <C-d> explicitly anchoring to beginning of file name is correct regarding vim's behavior. Feb 22 at 9:26

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.