3

When i go to command mode, type :e and press tab, i get like this

Excuse the file, directory writings on the right side (used for explanation)

A.cpp              file
Adamwathan/        directory
bucky.cpp          file
caleb/             directory
e.cpp              file
note.txt           file
vimtmp/            directory

I know about wildignore to ignore some files or directories.. and everything
but couldn't find anything to sort between files and directories

According to my need, i want files first, then directories sorted

A.cpp
bucky.cpp
e.cpp
note.txt
Adamwathan/
caleb/
vimtmp/

Can anyone help me make this config? :)

5

In the :help cmdline-completion section, see this paragraph discusses suffixes

                            *c_CTRL-D*
CTRL-D      List names that match the pattern in front of the cursor.
        When showing file names, directories are highlighted (see
        'highlight' option).  Names where 'suffixes' matches are moved
        to the end.
        The 'wildoptions' option can be set to "tagfile" to list the
        file of matching tags.

Then jumping to the :help suffixes page:

                        *'suffixes'* *'su'*
'suffixes' 'su'     string  (default ".bak,~,.o,.h,.info,.swp,.obj")
            global
    Files with these suffixes get a lower priority when multiple files
    match a wildcard.  See |suffixes|.  Commas can be used to separate the
    suffixes.  Spaces after the comma are ignored.  A dot is also seen as
    the start of a suffix.  To avoid a dot or comma being recognized as a
    separator, precede it with a backslash (see |option-backslash| about
    including spaces and backslashes).

Using this, you can include / in the suffixes option. You probably want to pre-pend this to the default option, using ^=

:set suffixes^=/
:set suffixes?
  suffixes=/,.bak,~,.o,.h,.info,.swp,.obj

With the default setting for suffixes, hitting <tab> after :e would show everything in alphabetical order:

:e
abc.vim  bbb/     def.vim  xyz.vim  yo/      ze/

After pre-pending / to the suffixes setting, the directories show up last:

:e
abc.vim  def.vim  xyz.vim  bbb/     yo/      ze/
5
  • if i'm not wrong, this works on all machines.. but doesn't work in nvim-qt on windows :(
    – Mega Bang
    Dec 22 '21 at 17:14
  • Is that because the directories are not listed with a backslash at the end? Is there another character or characters you could use to specify the end of a windows directory? Dec 23 '21 at 13:37
  • here's an example. I use this in my .vimrc set backupdir=C:\Users\User\Desktop\test\vimtmp\\ I tried 4 suffixes /,//,\,\\ all four but still no luck
    – Mega Bang
    Dec 23 '21 at 14:20
  • I would've thought that \\ would've been sufficient. Try \\\\. See :help option-backslash. Dec 23 '21 at 16:32
  • still doesn't work
    – Mega Bang
    Dec 24 '21 at 6:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.