Please change the default for 'wildmode'

173 views
Skip to first unread message

Christian Brabandt

unread,
May 9, 2018, 4:24:48 AM5/9/18
to vim...@vim.org
Bram,
can we please change the default for wildmode from "full" to
"list:longest,longest:full"?

Rationale: I have been working lately on a system with many files laying
around with complex names across a complex directory structure. On that
system I did not have my current vimrc config files around, only using
the vim that comes with git-bash.

However since I need to edit specific files it drives me actually nuts,
that the filename completion will complete to some random files and
there is no easy way to go back to the uncompleted typed filename so I
have to smash backslash until I find from where to correct the pattern
(plus one actually has to stare at the completed filename pattern and
double check that the completed name is actually the correct one).

I think only to complete the longest common match is a much more
sensible behaviour and does not cause confusion. In fact, sometimes I
did not even notice that Vim was completing the wrong filename for me,
until I wondered why I didn't find what I was looking for.

Attached patch does this change to defaults.vim

Best,
Christian
--
Testfahrer der A-Klasse schuften bis sie umkippen.
wildmode.patch

Tony Mechelynck

unread,
May 9, 2018, 4:42:28 AM5/9/18
to vim_dev, vim-dev
IMHO no particular choice can satisfy everyone. Happily we have the
vimrc to change the defaults which are not to our personal taste. For
instance the vimrc_example.vim (or the defaults.vim nowadays) has
":filetype plugin indent on" but just after calling it my vimrc has
":filetype indent off". Similarly my vimrc has

if has('wildmenu')
set wildmenu
if exists('+wildmode')
set wildmode=longest:full,full
endif
if !has('gui_running')
runtime! menu.vim
set wildcharm=<C-Z>
map <F10> :emenu <C-Z>
imap <F10> <C-O>:emenu <C-Z>
endif " ! !has('gui_running')
endif " 'wildmenu'

So what's the problem?

Best regards,
Tony.
> --
> --
> You received this message from the "vim_dev" 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_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Christian Brabandt

unread,
May 9, 2018, 6:25:11 AM5/9/18
to vim_dev

On Mi, 09 Mai 2018, Tony Mechelynck wrote:

> So what's the problem?

It is confusing and the chance that the first full match is actually the
one wanted by the user is lesser, the more matches there are.

This is a random example from my current system. It might differ if you
have those files not available. Try to edit this file on linux¹:
sp /usr/include/linux/netfilter/xt_time.h

Vim stops completing at directory boundaries (good, but already the
linux is completed to libdrm (after typing li<tab>), which is wrong).
But after typing x<tab> it will complete to x_tables.h and i have to
manually delete the t_time.h manually type "t<tab>" notice it is the
wrong match again (xt_AUDIT.h), manually delete again the _AUDIT.h, type
_t<tab> (completes to xt_tcpmss.h), delete it again and so on. By that
time I am better off, manually typeing the whole path (at least if I do
not make a typo). So in that case the whole filetype completion did not
help me.

Now consider a case where you have many long filenames that only differ
slightly by some numbers or letters. It makes completion so much painful
because you have to stare carefully at your commandline.

Yes I know about c_CTRL-D but I am just to used to typing <tab> from the
shell, and it stops automatically when it can't find a unique match.

¹) diretory looks like this here:
ipset xt_CONNMARK.h xt_comment.h xt_multiport.h
nf_conntrack_common.h xt_CONNSECMARK.h xt_connbytes.h xt_nfacct.h
nf_conntrack_ftp.h xt_CT.h xt_connlabel.h xt_osf.h
nf_conntrack_sctp.h xt_DSCP.h xt_connlimit.h xt_owner.h
nf_conntrack_tcp.h xt_HMARK.h xt_connmark.h xt_physdev.h
nf_conntrack_tuple_common.h xt_IDLETIMER.h xt_conntrack.h xt_pkttype.h
nf_log.h xt_LED.h xt_cpu.h xt_policy.h
nf_nat.h xt_LOG.h xt_dccp.h xt_quota.h
nf_tables.h xt_MARK.h xt_devgroup.h xt_rateest.h
nf_tables_compat.h xt_NFLOG.h xt_dscp.h xt_realm.h
nfnetlink.h xt_NFQUEUE.h xt_ecn.h xt_recent.h
nfnetlink_acct.h xt_RATEEST.h xt_esp.h xt_rpfilter.h
nfnetlink_compat.h xt_SECMARK.h xt_hashlimit.h xt_sctp.h
nfnetlink_conntrack.h xt_SYNPROXY.h xt_helper.h xt_set.h
nfnetlink_cthelper.h xt_TCPMSS.h xt_ipcomp.h xt_socket.h
nfnetlink_cttimeout.h xt_TCPOPTSTRIP.h xt_iprange.h xt_state.h
nfnetlink_log.h xt_TEE.h xt_ipvs.h xt_statistic.h
nfnetlink_queue.h xt_TPROXY.h xt_l2tp.h xt_string.h
x_tables.h xt_addrtype.h xt_length.h xt_tcpmss.h
xt_AUDIT.h xt_bpf.h xt_limit.h xt_tcpudp.h
xt_CHECKSUM.h xt_cgroup.h xt_mac.h xt_time.h
xt_CLASSIFY.h xt_cluster.h xt_mark.h xt_u32.h



Best,
Christian
--
Wer aus dem Rahmen fällt war vorher nicht unbedingt im Bilde.

Tony Mechelynck

unread,
May 9, 2018, 6:38:44 AM5/9/18
to vim_dev
With my longest:full,full setting I don't have to delete anything, I
just repeatedly hit the right-arrow key (or down-arrow to descend into
directories); if there are too many matches I can get an overview by
hitting Ctrl-D instead of <Tab>, then type something more specific
once I know what the choices are.

Best regards,
Tony.

Christian Brabandt

unread,
May 9, 2018, 6:44:23 AM5/9/18
to vim_dev

On Mi, 09 Mai 2018, Tony Mechelynck wrote:

> With my longest:full,full setting I don't have to delete anything, I
> just repeatedly hit the right-arrow key (or down-arrow to descend into
> directories); if there are too many matches I can get an overview by
> hitting Ctrl-D instead of <Tab>, then type something more specific
> once I know what the choices are.

Of course not that's why I am suggesting to change the IMHO unhelpful
default.

Best,
Christian
--
Experte: Ein Spezialist der über etwas alles weiß und über alles
andere nichts.
-- Ambrose Bierce

Cesar Romani

unread,
May 9, 2018, 7:24:35 AM5/9/18
to vim...@vim.org
On 09/05/2018 05:44 a.m., Christian Brabandt wrote:
>
> On Mi, 09 Mai 2018, Tony Mechelynck wrote:
>
>> With my longest:full,full setting I don't have to delete anything, I
>> just repeatedly hit the right-arrow key (or down-arrow to descend into
>> directories); if there are too many matches I can get an overview by
>> hitting Ctrl-D instead of<Tab>, then type something more specific
>> once I know what the choices are.
>
> Of course not that's why I am suggesting to change the IMHO unhelpful
> default.

I agree with that, the default setting for wildmode doesn't serve any
purpose.

--
Cesar

Dominique Pellé

unread,
May 9, 2018, 11:56:40 AM5/9/18
to vim_dev, vim-dev
I also never liked the default setting for 'wildmode'.
I find it even dangerous as it's easy to forget that there can
be multiple matches when doing completion.

Default completion is also different than bash completion
which probably confuses new users.

On the other hand, changing default settings in Vim
may upset some people.

Dominique

Bram Moolenaar

unread,
May 9, 2018, 4:54:29 PM5/9/18
to vim...@googlegroups.com, Dominique Pellé, vim-dev
I have the opposite opinion: I find the default bash completion
hopeless, having to type Tab multiple times and not knowing what will
happen next. Having to type another character is even worse (There is
only one Tab key, more than 26 other keys to chose from).

I suppose it depends on the number of file names and what you know about
them. If there are many matches then using Tab to go through them isn't
good. If there are few matches then using Tab is the best way, no need
to type letters.

Anyway, in case of doubt it's better to not change the default.

--
CRONE: Who sent you?
ARTHUR: The Knights Who Say Ni!
CRONE: Aaaagh! (she looks around in rear) No! We have no shrubberies here.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Bram Moolenaar

unread,
May 9, 2018, 4:54:31 PM5/9/18
to vim...@googlegroups.com, Christian Brabandt, vim...@vim.org
Well, I actually prefer "full". Mostly just because I'm used to it.

You can use Shift-Tab to go back to the uncompleted text (well, if
shift-Tab works on the terminal).

I think you always need to check if the completed name is the right one,
no matter what 'wildmode' is set to.

What do others think?

--
MESKIMEN'S LAW
There's never time to do it right, but always time to do it over.

David Fishburn

unread,
May 9, 2018, 5:37:53 PM5/9/18
to vim_dev
> What do others think?

I haven't tried the options to figure out what they do, so I will simply describe what I like.

In bash it drives me insane when I hit Tab and it only stops at the match and makes me type another character just to further complete.

I want:
1.  Tab to show the full file name
2.  I want to be able to cycle through those names each time I hit tab
3.  I want the status bar to show the matches, so I know (usually) how many times I have to hit tab

I get that already from my current settings, which seem to be just:
:set wildmenu  (on Windows)

Dave

Christian Brabandt

unread,
May 9, 2018, 5:59:10 PM5/9/18
to vim...@googlegroups.com

On Mi, 09 Mai 2018, Bram Moolenaar wrote:

> You can use Shift-Tab to go back to the uncompleted text (well, if
> shift-Tab works on the terminal).

Is that documented somewhere?

BEst,
Christian
--
Lieber einen von innen verstellbaren Außenspiegel,
als einen von außen verstellbaren Innenspiegel.

Tony Mechelynck

unread,
May 9, 2018, 6:22:40 PM5/9/18
to vim_dev, Christian Brabandt, vim-dev
On Wed, May 9, 2018 at 10:54 PM, Bram Moolenaar <Br...@moolenaar.net> wrote:
[...]
> What do others think?

I use ":set wildmenu wildmode=longest:full,full" (provided of course
that those settings are supported in the current Vim) and that suits
me (then I navigate the "wild menu" by means of arrow keys); but as I
said earlier, I also believe that no single default is going to
satisfy everyone and that happily we have the vimrc so each user can
tweak Vim to his (or her) own preferences.

In Bash I have to hit Tab twice to get a list of matches (the
equivalent of Vim's Ctrl-D). I like Vim better.

Best regards,
Tony.

Bram Moolenaar

unread,
May 10, 2018, 8:41:21 AM5/10/18
to vim...@googlegroups.com, Christian Brabandt

Christian wrote:

> On Mi, 09 Mai 2018, Bram Moolenaar wrote:
>
> > You can use Shift-Tab to go back to the uncompleted text (well, if
> > shift-Tab works on the terminal).
>
> Is that documented somewhere?

:he c_<S-Tab>

CTRL-P also works. I actually need to use that sometimes over ssh.

--
Proofread carefully to see if you any words out.

Christian Brabandt

unread,
May 11, 2018, 6:24:03 PM5/11/18
to vim...@googlegroups.com

On Do, 10 Mai 2018, Bram Moolenaar wrote:

>
> Christian wrote:
>
> > On Mi, 09 Mai 2018, Bram Moolenaar wrote:
> >
> > > You can use Shift-Tab to go back to the uncompleted text (well, if
> > > shift-Tab works on the terminal).
> >
> > Is that documented somewhere?
>
> :he c_<S-Tab>
>
> CTRL-P also works. I actually need to use that sometimes over ssh.

,----
| <S-Tab> *c_CTRL-P* *c_<S-Tab>*
| CTRL-P After using 'wildchar' which got multiple matches, go to
| previous match. Otherwise recall older command-line from
| history. <S-Tab> only works with the GUI, on the Amiga and
| with MS-DOS.
`----

I actually checked :h cmdline-complete (which contains this paragraph)
and I did not understand this. I know Ctrl-P gets the previous command
from the commandline but it wasn't entirely obvious to me, that you can
use it to undo the completion. So how about this paragraph:


diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 25577a2b6..c6608bbff 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -417,9 +417,12 @@ CTRL-N After using 'wildchar' which got multiple matches, go to next
match. Otherwise recall more recent command-line from history.
<S-Tab> *c_CTRL-P* *c_<S-Tab>*
CTRL-P After using 'wildchar' which got multiple matches, go to
- previous match. Otherwise recall older command-line from
- history. <S-Tab> only works with the GUI, on the Amiga and
- with MS-DOS.
+ previous match. After the first match undoes the last
+ completion and leaves the cursor at the previously entered
+ text. This is useful to change what will be completed.
+ Otherwise recall older command-line from history.
+ <S-Tab> only works with the GUI, on the Amiga and on MS-DOS.
+ In a terminal, Vim may not be able to recognize <S-Tab>.
*c_CTRL-A*
CTRL-A All names that match the pattern in front of the cursor are
inserted.



Best,
Christian
--
Auch das Chaos gruppiert sich um einen festen Punkt, sonst wäre es
nicht einmal als Chaos da.
-- Arthur Schnitzler

Christian Brabandt

unread,
May 13, 2018, 12:34:48 PM5/13/18
to vim...@googlegroups.com

Bram,
> I actually checked :h cmdline-complete (which contains this paragraph)
> and I did not understand this. I know Ctrl-P gets the previous command
> from the commandline but it wasn't entirely obvious to me, that you can
> use it to undo the completion. So how about this paragraph:
>
>
> diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
> index 25577a2b6..c6608bbff 100644
> --- a/runtime/doc/cmdline.txt
> +++ b/runtime/doc/cmdline.txt
> @@ -417,9 +417,12 @@ CTRL-N After using 'wildchar' which got multiple matches, go to next
> match. Otherwise recall more recent command-line from history.
> <S-Tab> *c_CTRL-P* *c_<S-Tab>*
> CTRL-P After using 'wildchar' which got multiple matches, go to
> - previous match. Otherwise recall older command-line from
> - history. <S-Tab> only works with the GUI, on the Amiga and
> - with MS-DOS.
> + previous match. After the first match undoes the last
> + completion and leaves the cursor at the previously entered
> + text. This is useful to change what will be completed.
> + Otherwise recall older command-line from history.
> + <S-Tab> only works with the GUI, on the Amiga and on MS-DOS.
> + In a terminal, Vim may not be able to recognize <S-Tab>.
> *c_CTRL-A*
> CTRL-A All names that match the pattern in front of the cursor are
> inserted.

Did you intentionally not include this change?

Best,
Christian
--
Wo man die Liberalität aber suchen muss, das ist in den
Gesinnungen, und diese sind das lebendige Gemüt.
-- Goethe, Maximen und Reflektionen, Nr. 355

Bram Moolenaar

unread,
May 13, 2018, 4:16:06 PM5/13/18
to vim...@googlegroups.com, Christian Brabandt
I mentioned in another thread: I split this into two entries, one for
CTRL-P and one for <S-Tab>. They are actually more different, using one
entry is confusing.

--
BEDEVERE: How do you know so much about swallows?
ARTHUR: Well you have to know these things when you're a king, you know.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

Christian Brabandt

unread,
May 14, 2018, 1:50:00 AM5/14/18
to vim...@googlegroups.com

On So, 13 Mai 2018, Bram Moolenaar wrote:
> I mentioned in another thread: I split this into two entries, one for
> CTRL-P and one for <S-Tab>. They are actually more different, using one
> entry is confusing.

I still think it is useful to mention, that this undoes the completion,
as this is not entirely obvious to the reader. So please include the
following update to the documentation:

diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index d7a026143..fd8507fc3 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -421,8 +421,11 @@ CTRL-N After using 'wildchar' which got multiple matches, go to next
match. Otherwise recall more recent command-line from history.
*c_CTRL-P*
CTRL-P After using 'wildchar' which got multiple matches, go to
- previous match. Otherwise recall older command-line from
- history.
+ previous match. After the first match undoes the last
+ completion and leaves the cursor at the previously entered
+ text. This is useful to change what will be completed.
+ Otherwise recall older command-line from history.
+
*c_CTRL-A*
CTRL-A All names that match the pattern in front of the cursor are
inserted.


Best,
Christian
--
Der Aberglaub', in dem wir aufgewachsen,
Verliert, auch wenn wir ihn erkennen, darum
Doch seine Macht nicht über uns.
-- Gotthold Ephraim Lessing (Nathan der Weise)

Bram Moolenaar

unread,
May 14, 2018, 3:31:34 PM5/14/18
to vim...@googlegroups.com, Christian Brabandt
Well, this also applies to <S-Tab>. And if you type CTRL-P enough times
you also get back to where you started. Let's add a remark below:

When repeating 'wildchar' or CTRL-N you cycle through the matches, eventually
ending up back to what was typed. If the first match is not what you wanted,
you can use <S-Tab> or CTRL-P to go straight back to what you typed.

--
It is illegal for anyone to give lighted cigars to dogs, cats, and other
domesticated animal kept as pets.
[real standing law in Illinois, United States of America]
Reply all
Reply to author
Forward
0 new messages