37

I'm using VS Code 1.25.1 on Win10. When I open the Explorer icon and look at a list of files in a folder, it shows the files listed alphabetically. I want to sort them by date modified, but I don't see any options to sort by other fields. Are there keyboard shortcuts? Any other options? Thanks.

3 Answers 3

45
  1. Open user settings (Mac: cmd+, Windows/Linux: ctrl+,).
  2. If you want this new sort order to apply to all VSCode projects, continue to step three. If you want it to apply only to the currently opened folder/workspace, first click on the "Workspace" tab that's directly below the settings search bar, then continue to step three.
  3. Using the settings search bar, search for the following setting ID: explorer.sortOrder.
  4. Click the dropdown for that setting and select your preferred sort order (in your case, modified).
  5. If you'd like to quickly toggle this setting between different values (via a keyboard shortcut), use the Settings Cycler extension.
3
  • 1
    Thx for responding. I see the options now: 'mixed' (files and folders sorted combined) 'type' (by file type) 'modified' (by last modified date) 'filesFirst' (sort files before folders) The next logical question is can we toggle between values with keyboard shortcuts or another technique?
    – Tom
    Jul 26, 2018 at 20:36
  • Updated answer with option for adding a keyboard shortcut to toggle between the different values. Dec 4, 2019 at 19:48
  • Does anyone know if this can be done to only one specific sub-folder?
    – xiphe
    Jan 20 at 10:53
25

A more user friendly approach can be:

  1. Open the workspace settings:

    Ctrl+Shift+p

    And open: Preferences: Open Workspace Settings.

  2. Browse to Features > Explorer using the sidebar.

    Open worlspace settings

  3. Use the Sort Order option to customise sorting.

    Select Sort Order in settings

5

So interestingly the Sort Order setting only seems to impact folders and files within the top-level workspace folders, if those top-level folders were added via the Add folder to workspace option.

For ex I had

Workspace
- ProjectA
- ProjectB
- ProjectC

Then I added another folder to the workspace, and it appeared at the bottom of the list. Because it was a top-level folder the Sort Order setting would not impact its order in the list. The Sort Order would only impact the files and folders within each of those ProjectX folders.

To fix this I directly edited the workspace file. To do so, open it with a text editor other than VSCode, and change the order of listed files.

For ex, mine looked like:

{
  "folders": [
    {
      "path": "../../Desktop/ProjectA"
    },
    {
      "path": "../../Desktop/ProjectB"
    },
    {
      "path": "../../Desktop/ProjectC"
    },
    {
      "path": "../../Desktop/NewProject"
    }
  ],
  "settings": {}
}

and all I had to do was change it to:

{
  "folders": [
    {
      "path": "../../Desktop/NewProject"
    },
    {
      "path": "../../Desktop/ProjectA"
    },
    {
      "path": "../../Desktop/ProjectB"
    },
    {
      "path": "../../Desktop/ProjectC"
    }
  ],
  "settings": {}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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