Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sort files in emacs dired?

Emacs dired mode is an easy to use text-based file manager. By default, files are displayed in alphabetical order. Is there a way to sort the files by file size descending order?

like image 216
Nick Avatar asked Dec 09 '14 12:12

Nick


People also ask

What is dired mode in Emacs?

Dired makes an Emacs buffer containing a listing of a directory, and optionally some of its subdirectories as well. You can use the normal Emacs commands to move around in this buffer, and special Dired commands to operate on the listed files. Dired works with both local and remote directories.

How do you use dired?

With Dired, you can mark files for deletion using the d key. Once you have selected the files you want to delete, you can type x to initiate the deletion process. You will be prompted with a warning and must type yes or no to complete or abort the deletion.

How do I move files in Emacs?

Open dired for a directory containing files you want to work with. Then use C , R , or D when the cursor is on the line of a file to copy, rename/move or delete the file, respectively. This can also be done for multiple files by marking them.


2 Answers

You may customize the sort order by providing an argument to the dired-sort-toggle-or-edit which is bound to the s keystroke.

So to answer your question, just type Control+u s and pass the -lS switches. You may pass -lhS for human readable results.

like image 195
Tassos Avatar answered Oct 14 '22 01:10

Tassos


You might want to use the extension dired-quick-sort. After setting it up, push "S" to display a sorting menu that offers many different ways to sort, including file size.

Disclaimer: I am the author of the extension.

like image 44
xuhdev Avatar answered Oct 14 '22 02:10

xuhdev