Reputation: 641
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.
Upvotes: 64
Views: 52963
Reputation: 6758
jq
if you don't already have it~/your.code-workspace
for examplejq '.folders |= sort_by(.path)' ~/your.code-workspace > ~/tmp.$$.json && mv ~/tmp.$$.json ~/your.code-workspace
It uses the |=
"update" operator to sort folders, then puts the result in a temporary file ($$
generate a random number to avoid collision) and overrides the original workspace file with this file.
Upvotes: 0
Reputation: 71
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": {}
}
Upvotes: 7
Reputation: 50048
explorer.sortOrder
.modified
).Upvotes: 69
Reputation: 12489
A more user friendly approach can be:
Open the workspace settings:
Ctrl+Shift+p
And open: Preferences: Open Workspace Settings
.
Browse to Features > Explorer using the sidebar.
Use the Sort Order
option to customise sorting.
Upvotes: 33