Saturday, June 15, 2024

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

On Fr, 14 Jun 2024, Enan Ajmain wrote:

> On Fri, 14 Jun 2024 22:52:10 +0200
> Christian Brabandt <cblists@256bit.org> wrote:
> >
> > 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.
>
> I think the cnoremap only maps 'B' to expand to "b */" if it's at the
> start of the commandline. But what's "b */" supposed to do? I added
> this mapping and then typed "deep" (so the whole commandline became "b
> */deep" and then pressed tab. It didn't do anything. No completion.

Ah Windows, I didn't think about it. So unless you use shellslash,
you'll need to change the mapping to use a backslash instead:

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

> Could you explain the logic behind "anchored to the directory
> separator"?

The idea is, that you want everything that you typed to be matched after
a directory separator. So instead of :b deeplog<tab> which presents you
with 3 different files, anchor the pattern to the directory separator:
\deeplog.py which Vim shall then only complete if it matches the
directory separator followed by whatever you enter.

> Note that I also tried "b *\" and "b *\\" since I'm in Windows.

Try if :b *\<pattern><tab> works for you.


Thanks,
Christian
--
Unfair animal names:

-- tsetse fly -- bullhead
-- booby -- duck-billed platypus
-- sapsucker -- Clarence
-- Gary Larson

--
--
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/Zm2eN1txfljI05dC%40256bit.org.

No comments:

Post a Comment