How can I sort my project folders by names?

I have a lot of project folder in my Atom editor. How can I sort it by names, not by adding date?

3 Likes

You mean like this?


https://cloud.githubusercontent.com/assets/21340/5293848/ab24145a-7b47-11e4-946f-9e58eb74df6d.gif

I’m not sure if this works for multiple root folders. Try it?

No. I mean project folders like “tree-view” in your picture.

Please go to the settings page shown in the screenshot, then select “Sort Folders Inline” and see if that does what you want.

You currently can’t sort project folders, unfortunately. The Sort Folders Before Files option (renamed from Sort Folders Inline - that’s a really old screenshot) only applies to subfolders / files of project folders.

That’s bad. :frowning:

Do you know about a issue/feature request about it? It would be great to just drag and drop to sort (with ctrl to copy…).

I was able to fix this problem by putting the following in my init.coffee script:

arrayEqual = (a, b) ->
  a.length is b.length and a.every (elem, i) -> elem is b[i]

sortPaths = (projectPaths) ->
    paths = atom.project.getPaths()
    paths.sort()
    if not arrayEqual(paths, projectPaths)
        atom.project.setPaths(paths)

sortPaths([])
atom.project.onDidChangePaths(sortPaths)
5 Likes

It would be awesome to turn this into an API for sorting the project paths (both project paths and file/folder paths) so people could implement this however they want.

Thanks a lot for sharing this, drelyn86! It’s way better than the default (sorting by date added).

At some point atom should really allow to rearrange project folders in tree-view via drag and drop, though.

If this is possible then it’s also possible to sort them manually (drag and drop, alphabetically, date, etc…). This should be a default option in the tree view. Thanks @drelyn86 for this solution. Works perfectly.

1 Like

For now there is a package that does sorting by alphabetical order - https://atom.io/packages/atom-sort-projects

There will be first class support for DnD once this PR is merged - https://github.com/atom/tree-view/pull/525

The PR (#525) has been merged, and using drag and drop to sort projects now works since version 1.13.0 - https://github.com/atom/atom/releases/tag/v1.13.0 :grinning: :tada: