[HN Gopher] Emacs dired-mode as a file manager
       ___________________________________________________________________
        
       Emacs dired-mode as a file manager
        
       Author : todsacerdoti
       Score  : 44 points
       Date   : 2025-05-23 18:46 UTC (4 hours ago)
        
 (HTM) web link (lynn.sh)
 (TXT) w3m dump (lynn.sh)
        
       | paulyy_y wrote:
       | The insanity of trying to shoehorn everything into emacs, even
       | calling it an OS, is purely beyond.
        
         | snapdaddy wrote:
         | How many editors can you think of that don't do any (strictly)
         | unnecessary file operations, e.g. renaming files? The author's
         | problem is that Emacs is just really good at it, so he wants to
         | use it more.
        
         | bigdict wrote:
         | Once you realize that elisp is a better shell programming
         | language than bash, it ceases to appear insane.
        
         | hollerith wrote:
         | I much prefer them to the people that try to shoehorn
         | everything user-facing into the browser.
        
           | internet_points wrote:
           | s/browser/llm
        
         | tadfisher wrote:
         | Emacs is a shell, not an OS. It's an extremely customizable and
         | programmable shell that works with many third-party utilities,
         | but it's still a shell.
        
           | rbc wrote:
           | I'd call it more than a shell. It's more like a text oriented
           | Lisp (Emacs Lisp to be specific) runtime environment with
           | built in editing, interpretation, compilation, and debugging
           | tools. It's also been a popular home for numerous
           | applications that have found lives of their own, far beyond
           | editing text.
        
         | timewizard wrote:
         | It gives me fewer reasons to leave Emacs. Which increases my
         | productivity. There's very little 'mental context switch' delay
         | since it's all the same tool with the same interface.
        
       | SoftTalker wrote:
       | My file manager is the shell and the utilities like cp, mv, rm,
       | find, xargs, grep, etc.
       | 
       | Have never felt the need for anything beyond that.
        
         | trey-jones wrote:
         | dired-mode is fairly necessary in emacs to preserve the
         | continuity of what you are editing.
         | 
         | For example, if I'm editing a file called originalfilename.txt,
         | and I decide it should be called newfilename.txt, I can mv
         | originalfilename.txt newfilename.txt in the terminal and it's
         | all good, but you're still editing the buffer
         | originalfilename.txt in emacs and if you save it you will have
         | a new file with that name.
         | 
         | Using dired to change the filename updates all the buffers that
         | are using that file.
         | 
         | dired gets some hate, I think because it creates a lot of
         | buffers and they tend to stick around, but it's never bothered
         | me.
        
           | partdavid wrote:
           | I'm also an emacs user in the habit of using the shell for
           | file management, and I just deal with this mismatch. It
           | hasn't been annoying enough for me to solve by switching to
           | something else. But then again, I guess I don't do a lot
           | "file management", whatever that really means.
        
         | sfpotter wrote:
         | Just because you've never felt the need doesn't mean you aren't
         | stuck in a local minimum.
        
       | susam wrote:
       | I didn't see this mentioned in the article, so I thought I would
       | mention it here:
       | 
       | Dired stands for _directory editing_.
       | 
       | One of my favourite features of Dired is the ability to mark or
       | unmark multiple files in a variety of ways: manually, using
       | repetition counts, or with regular expressions. This can be done
       | fluidly and spontaneously as we browse and inspect files. Once
       | we're satisfied with our selection, we can perform bulk
       | operations on them such as copying, moving, deleting, changing
       | permission bits, compressing the marked files, etc.
       | 
       | It's a bit like how we can use a GUI desktop environment to mark
       | multiple files and then perform bulk operations on them. This is
       | something we cannot easily do on the shell with the standard Unix
       | utilities. But we can do all of this from within Emacs using very
       | concise sequence of keystrokes and muscle memory.
       | 
       | Further, unlike most GUI desktop environments, every Dired
       | interaction is scriptable, recordable, and replayable. I mean
       | every operation or key sequence in Dired is available as an Elisp
       | function, so we can script repetitive tasks by writing small
       | Elisp snippets. Or, alternatively, we can have Emacs record the
       | repetitive actions as keyboard macros, which we can then replay
       | as many times as needed. I no longer have to worry whether the
       | underlying GUI desktop environment supports these features or not
       | because I know Emacs does and I can just use Emacs to browse my
       | system.
       | 
       | And that brings me to another important benefit of using Dired:
       | my muscle memory for Dired is transferable across a wide variety
       | of systems and environments. It doesn't matter whether I'm
       | working locally or logged into a remote shell, or whether I'm on
       | macOS, Xfce4, KDE, etc. I can browse and edit my files and
       | directories in exactly the same way using the same muscle memory
       | and the same set of Dired commands, key sequences, and features!
       | 
       | A couple of years ago, I used to host Emacs book club meetings.
       | I've kept some notes on directory editing with Dired from those
       | sessions here: <https://susam.net/cc/mastering-
       | emacs/ch06.html#dired>.
        
         | sixtyj wrote:
         | So it is similar to Total Commander, but in editor. Or Double
         | Commander...
        
           | mimischi wrote:
           | Just that it's all done from the comfort of the editor one
           | knows and loves, with the same key binding and semantics that
           | at there, whether you edit files in fired, write code, a
           | commit message or an email.
           | 
           | Not to get too deep into this, but there's this warm fuzzy
           | feeling of not having to use /yet another different app/
           | that's ever so slightly different to the optimal workflow you
           | have otherwise
        
       | 90s_dev wrote:
       | The one thing I miss about dired-x is being able to edit multiple
       | filenames simultaneously in the same way you do edit a file using
       | multiple cursors, and commit the changes all at once. Can someone
       | make that work in Windows Explorer or VS Code please?
        
       | perihelions wrote:
       | > _" Opening them from dired-mode already puts them into emacs,
       | so"_
       | 
       | This also works globally with #'find-file-at-point (which isn't
       | bound to a hotkey by default, but should be: this is one of my
       | most satisfying hotkeys. That function opens any filepath
       | appearing as a string, in any context, in the working directory
       | of that context--filepath strings in files, and filepath strings
       | as outputs from shell commands, being the top two).
       | 
       | (It's like converting every file reference into a clickable URL--
       | only, implicitly).
        
         | ruricolist wrote:
         | If you just do C-x C-f, M-n to get the "next completion" gives
         | you the file at point.
        
       | ww520 wrote:
       | In dired-mode, I want to have a split view of the directory
       | listing on the left window and to quickly browse the content of
       | each file on the right window. The default file visit command
       | keeps opening a new window for each file which needs closing.
       | It's really annoying. I put the following in init.el file and
       | bind it to a key. It loads the current file under the cursor in
       | the next existing window on right, on left, above, below, or
       | opening a new window as needed.                 ;; In dired mode,
       | visit the file at the cursor in the right/below/left/above
       | window.       (defun my-dired-display-direction ()
       | (interactive)         (let* ((file-or-dir (dired-get-file-for-
       | visit))   ;; get the file at cursor                (buffer (find-
       | file-noselect file-or-dir))) ;; load the file into a buffer
       | (let ((window                                   ;; figure out the
       | window to use                  (cond ((get-buffer-window buffer
       | (selected-frame)))                        ((window-in-direction
       | 'right))     ;; try window in each direction
       | ((window-in-direction 'below))     ;; and default to right
       | ((window-in-direction 'left))      ;; if no window found.
       | ((window-in-direction 'above))                        (t (split-
       | window (selected-window) nil 'right)))))             (window--
       | display-buffer buffer window 'window nil)             window)) )
       | ;; Bind ctrl-o to display at direction.       (define-key dired-
       | mode-map (kbd "C-o") 'my-dired-display-direction)
        
       | entropie wrote:
       | I use dired for a long time now and at first it felt a bit weird
       | but not anymore. The ultimate killer feature is wdired [1] that
       | make the dired buffer writeable and you can edit
       | text/filenames/permissions like in any other emacs buffer and
       | commit the changes with C-c C-c.
       | 
       | 1:
       | https://www.gnu.org/software/emacs/manual/html_node/emacs/Wd...
        
       | ews wrote:
       | The most amazing part of guix (and nixOS) is that you can just
       | copy that piece of code into your home-config.scm and have it
       | running in a few seconds. It's pretty mind blowing.
        
       | julienchastang wrote:
       | wdired-change-to-wdired-mode, FTW! :-) An extremely cool feature
       | is dired buffers are _editable_ for changing file names and
       | permissions. You can even use this feature, en masse, with other
       | features like rectangle edit.
        
         | tcoff91 wrote:
         | Can you copy a line and paste it in a different directory to
         | copy a file?
         | 
         | Oil.nvim provides an incredible experience for managing files.
         | It'll even use the LSP to fix imports if you move files from
         | place to place.
        
       | teddyh wrote:
       | Slight nitpick: It's no longer called a "MIME Type", it's now
       | called an "Internet Media Type".
        
       | shwouchk wrote:
       | my absolute favorite feature of dired is rw mode (^x ^q) - edit
       | your dir like a normal text file. use regex replacement, macros
       | with counters, multi cursor - whatever you like. See the result
       | of your edits, commit bam. much more fun than piping find through
       | something
        
       ___________________________________________________________________
       (page generated 2025-05-23 23:00 UTC)