Friday, June 14, 2024

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

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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/Zmytev/J%2BUjT7XXH%40256bit.org.

No comments:

Post a Comment