Vscode: Explorer / Opened Editors Sorting

Created on 25 May 2017  Â·  38Comments  Â·  Source: microsoft/vscode

Numerous issues have been filed on this topic, merging them into one.

Done

  • [x] Option for sorting files by type in Explorer #5222
  • [x] Give an option to show files before directories in file explorer #22529
  • [x] Make listing directories first an option #29329
  • [x] Add option to sort files in Explorer side-bar by date modified #11823

Open

  • [ ] Align explorer sorting with platform sorting #27759
  • [ ] Feature Request: api to custom files sort order at the sidebar #12345
  • [ ] Add sorting to Open Editors list #12453
  • [ ] Choose a sort order of directories and files according to the settings pattern #23231
  • [ ] Feature to assign a particular file name to appear first in a directory listing #25724
  • [ ] Explorer order files names with underline #40679
feature-request file-explorer

Most helpful comment

I would like to have an option to sort the opened editors list by alphabetical order. To be honest, I don't know why that is not the default. The current sort order doesn't make sense to me (and never helps me to find what I want).

All 38 comments

Want to add one more;
If explorer have 100's of files, scrolling down to find the right one is painful. Will be great if we can type in the file or first few chars and explorer will scroll down to the right file

agree with the "file filtering" feature - with and without sorting

I would like to have an option to sort the opened editors list by alphabetical order. To be honest, I don't know why that is not the default. The current sort order doesn't make sense to me (and never helps me to find what I want).

Working with TypeScript, it would be great to have the barrels (index.ts) sorted at the top.
Would that be possible?

Everything to complete an IDE is perfect for me! Organization is all in one project!

to add to #12345
can we have an option to write our own order in json array inside .vscode ? it would make it super easy, the order will follow the order in the array. and also the default json array to always be updated based on the defaults for arrangement , so that if i want to start editing the ordering again from scratch, it would be easy. thanks so much, this is the best text editor ever.

@Macromeda Check my issue #23231

@slowaways my idea is to make a json that holds the actual names of the files in the project folder, not ordering by characters.

We really need this feature. Alphabetical sorting in the Open Editors panel. Thanks...

Ordering by path would be my ideal. When working with huge repos, sorting by alphabetical filename wouldn't cut it as I like to keep my editors organised by where they appear in the codebase.

e.g. this...

Button.js src/components
Card.js src/components
Input.js src/components
Navigation.js src/components
Auth.js src/redux
People.js src/redux
User.js src/redux
map.js src/utils
parse.js src/utils
sort.js src/utils

would be much more useful (to me) than this...

Auth.js src/redux
Button.js src/components
Card.js src/components
Input.js src/components
map.js src/utils
Navigation.js src/components
parse.js src/utils
People.js src/redux
sort.js src/utils
User.js src/redux

This is especially true when working on goliath monorepos.

I cannot understand why the ordering is so strange: why the 2016xml files are listed after 2018xml ?

image

Maybe the default ordering is TextNoCase ASC? A-Z. It is parsing the file name as text rather than a numeric?

Looks like is parsing as numeric instead; has is the output of ls | sort -n

I don't know if this has been suggested before (or even if it's possible with an extension) but I always prefer to keep the open editors list managed as a mini-tree. i.e. identical to the main folder/files views, but only for open files. I appreciate you can see the folder paths after the file names, but the code I work on has so many similar/identically named files (where only the path differs) that this "extra" data is actually the most important part to me.

I've filed this issue against the strange sort order: "File extensions affect Explorer's sort order"
https://github.com/Microsoft/vscode/issues/67154

Use case: I have writing projects (ex: user manual, journal article, book) with sections, sub-*-sections, files. I frequently reorganize the sequence as I work, drag, insert, delete, regroup. I want my work in the explorer to be in the desired sequence without having to rename anything.

Probably no one "best" way to do this, so create an API through which the item-by-item sequence of items in the explorer can be specified, which will allow extensions to provide various options. It should probably also enable a little sort menu so that the sort can be switched with just a click: default <> global:myjsprojects <> global:mytaxprojects <> recents <> local:custom1 <> local:custom1:todo

I would probably like direct drag-and-drop reordering (that remembered my custom order when switching between custom and other sort orders), but that might risk hard-coding something someone doesn't like. Maybe I wouldn't like it. So, I'd probably be just as happy with a FooSort extension that had me sort the items in its own fooSortOrder.config files that could be global and/or local. I could drag and drop items in those almost as easily (as long as it wasn't JSON!), and a file like that could have more sort options. Different extensions could experiment with different sort order specification languages in their own config files (these files at top & bottom, others alpha in middle; or this folder numeric, this folder custom, default folder alpha; or whatever).

I've just coded a barrel-first sort order option for the explorer view that, while not providing the customization levels asked for in this issue, addresses one desire I'm sure I'm not the only one to have: sorting barrel files (index.ts, index.js, etc.) below folders but above all other files. It is mentioned in #25724 and in a comment on #12345.

I couldn't find the API and don't believe it exists to perform this in an extension. I'd be happy to change this into an extension if someone knows how to either extend or patch the explorerViewer. Reproducing File Explorer with Tree View in an extension for this one tiny feature I feel is overkill so this is why the pull request.

I agree that when I write TypeScript, I want index.ts on top, and for C, I want .c (the entry point) on top. When I write the user guide, I want my outline on top, when writing a book, I want an outline on top of each section. Whatever the definition of barrel file may be, it will either be hard-coded to the wrong choice for what many people want on top in many cases, or it will be configurable, in which case you may as well put your configuration in a config file that offers more options than just top file but doesn't require them.

I'm finding now that even the annoying workaround of renaming files to force a display sequence via alphabetical order isn't predictable with underscores, casing, extensions, different OSes, etc., making me wish I could configure what "alphabetical" means to me. A display order API for extensions would enable extensions to configure that, too.

A trivial sort order which isn't without merit is none (or preserve). It should result in file system dependent sort order. For NTFS this is largely a lexicographic sort order but I know this isn't the case with all file systems. But it requires that the order of files in array from readdir is never changed by any code that touches the array.

But the open editors list isn't tied to readdir. as an example I just opened a project. no files are open yet. hit cmd-n to open a new untitled/unsaved editor.. did this again. clicked on untitled-1. cmd-n again. clicked on untitled-1 again and cmd-n a 4th time. the order in open editors matches the order of the tabs: untitled-1, untitled-4, untitled-3, untitled-2..

But the open editors list isn't tied to readdir. as an example I just opened a project. no files are open yet. hit cmd-n to open a new untitled/unsaved editor.. did this again. clicked on untitled-1. cmd-n again. clicked on untitled-1 again and cmd-n a 4th time. the order in open editors matches the order of the tabs: untitled-1, untitled-4, untitled-3, untitled-2..

Wrote it in reply to file explorer sorting. As I understood this is the thread after consolidation. I could be wrong.

I've also been trying to order the files in my explorer window, and having to deal with the fact that the sorting is not actually alphanumeric/lexicographic!
For instance, the file 51_lattices_metric.tex appears after the file 6_modular_forms.tex, whereas if I change it to 5_1_lattices_metric.tex it moves before the file 5_lattices.tex; what I'd really like is for the lattices_metric.tex file to be between 5_lattices.tex and 6_modular_forms.tex.

Managed to reproduce OPEN EDITORS not sorting when dragging files into VS Code.

https://github.com/microsoft/vscode/issues/80681#issuecomment-539862813

two years later , this still pending ?

@isidorn can you escalate this to a higher level? Is anyone from Microsoft or the vscode group going to code anything because all I see is you closing PRs and issues that you think are duplicates or out of scope.

+1

I'm currently using this extension for sorting opened files:
https://marketplace.visualstudio.com/items?itemName=Divni.open-files

But now switched to what @reyronald suggested:
https://marketplace.visualstudio.com/items?itemName=omagerio.tabsort

Sorry, I found that 'tabsort' extension is not working. I have to switch back to "Open-files".

Works fine for me, enable the extension close all editors, then start
opening again, and they are sorted

nengxu wrote on 1/23/20 4:30 PM:
>

Sorry, I found that 'tabsort' extension is not working. I have to
switch back to "Open-files".

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/vscode/issues/27286?email_source=notifications&email_token=AASHOIQ7P32UQ6N3KWRPBB3Q7IEATA5CNFSM4DM2ZIO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJY5PYY#issuecomment-577886179,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AASHOIUUDHQAMF4BXIJPA23Q7IEATANCNFSM4DM2ZIOQ.

Unlike many of the other requests, I'd like to propose a small change and have made commit showing the proposed changes on a VS Code fork. https://github.com/jeff-hykin/vscode/commit/70fb0f8eec170db4ddc274be0089d20dcaa9250e

I've been redirected to this issue/thread, so here is my original request

Why is this a problem (pseudo-bug)

Sorting files by both filesFirst and modified (timeModified) is certainly possible, but VS Code treats them as mutually exclusive. It seems very strange to me to include a mixed option, and modified and option, but not a mixed--modified option.

For example, here's what the current VS Code options could more aptly be named:
filesFirst--alphabetically
mixed--alphabetically
foldersFirst--alphabetically
foldersFirst--timeModified
foldersFirst--type
But for obvious reasons switching to a naming scheme like that would quite a bit less than ideal.

A Backwards Compatible, Future-Proofed, ~20-line API Proposal

I'd like to propose that explorer.sortOrder optionally accept an array of sort methods.
explorer.sortOrder: SortMethod | SortMethod[]

enum SortMethod {
    filesFirst   = "filesFirst",
    mixed        = "mixed",
    default      = "default",
    modified     = "modified",
    type         = "type",

    // additional options (see below for justification)
    foldersFirst = "foldersFirst",
    alphabetical = "alphabetical", 
}

Behavior and Examples

{
    "explorer.sortOrder": [ "type" ]   // equivalent to "mixed--type" 
}

```jsonc
{
"explorer.sortOrder": [ "type", "alphabetical" ]
// files are mixed (by default)
// files then primarily sorted by type
// files with the same type are then sorted alphabetically
}

```jsonc
{
    "explorer.sortOrder": [  "filesFirst", "type", "modified"  ]
     // files primarily sorted with files at top
     // files and folders are sorted by extension name
     // files with the same extension name are then sorted by timeModified
}

Example Implementation

https://github.com/jeff-hykin/vscode/commit/70fb0f8eec170db4ddc274be0089d20dcaa9250e

Why this is ideal

  • The API change is about as minimal as an API change can possibly be
  • The naming will still make sense (arguably will make more sense after the change)
  • The additional codebase complexity is minimal and modular
  • Makes space for future functionality such as timeCreated or descending/ascending sorts
  • It allows the user to make the choice for a desirable customization at the cost of some performance (many of us have plenty of performance to spare)

Looking for an API to sort files in a custom way. "Feature Request: api to custom files sort order at the sidebar". I want to implement .sortfile file format (https://github.com/sortfile/sortfile) in vscode.

I have Explorer Sort Order set to default in version 1.45.1 on macOS. I've got a folder of files that have a hex code prefix of fixed length from using Alembic SQL migrations. It is quite frustrating that the sort order isn't the same as using ls in a terminal which lets me see the migration files in alphabetic (increasing hex) order. I can't quickly click on the file to open one without searching files by typing in the hex code. This issue is similar to that in https://github.com/microsoft/vscode/issues/27286#issuecomment-415001567 above.

I would like to have an option to sort the opened editors list by alphabetical order. To be honest, I don't know why that is not the default. The current sort order doesn't make sense to me (and never helps me to find what I want).

Yes, yes, yes! Open Editors tab is almost useless to me; I have hundreds of source files open, really need a sort option, been waiting on this feature for years now!

Sort tabs alphabetically and group by file extension:

https://marketplace.visualstudio.com/items?itemName=marcusviar.sort-tabs

Please read the know issues section of the readme before use.

It took me almost an hour to find this issue! I would like to echo the others in this thread: I want to move my index files below folders, but above other files. Have any API changes been made where an extension could do this? I would like to create an extension if so. Alternatively, maybe a new workspace.sortOrder that mentions something about indexFirst? I'm not sure what would be best, but I'd love to help if possible.

@seiyria, we've been trying to push this for years now but @isidorn doesn't live here anymore, he just comes past every now and then to close issues he doesn't want to work on. The fork on my profile allows sorting index files first, but I haven't kept the fork up to date with all the other changes since I made it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NikosEfthias picture NikosEfthias  Â·  3Comments

omidgolparvar picture omidgolparvar  Â·  3Comments

VitorLuizC picture VitorLuizC  Â·  3Comments

sijad picture sijad  Â·  3Comments

philipgiuliani picture philipgiuliani  Â·  3Comments