Re: ":b {bufname}" tab-completion uses whole filepath

Christian Brabandt <[email protected]>
Newsgroups gmane.editors.vim
Message-ID <Zmytev/[email protected]>
On Fr, 14 Jun 2024, Enan Ajmain wrote:

> I use ':b' quite often.  And I use a substring of the bufname to jump to
> that buffer.  Works quite well.
> 
> But a problem is that the substring I provide isn't only matched with
> the buffer names but also the filenames.  See these examples:
> 
>     :ls
>       1 #h   "example\predict.py"           line 25
>       2  a   "deeplog\deeplog.py"           line 0
>       4 %a   "example\train.py"             line 37
>     :b deep<tab>
> 
> Then when I type ":b deep<tab>", the matches shown are:
> 
>     E:\projects\log-parsing\deeplog\example\predict.py
>     deeplog\deeplog.py
>     E:\projects\log-parsing\deeplog\example\train.py
> 
> We can see that vim is matching the filepaths instead of only the buffer
> names.  Can I change this behavior?  Preferably with vimscripting, but
> I'm willing to change source code too since I use this too often.
> 
> To be clear: I want only this match to be shown:
> 
>     deeplog\deeplog.py

You could try the following mapping:

:cnoremap <expr> B getcmdtype()==#':'&&getcmdpos()==1?'b */':'B'

And then type :B which would expand to :b */ on the commandline and then 
whatever you type would be anchored to the directory separator.

Thanks,
Christian
-- 
TAILFINS!! ... click ...

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/Zmytev/J%2BUjT7XXH%40256bit.org.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.