(or emacs irrelevant)

Even more dired key bindings

I've posted about dired quite a few times now. Below, I'll do a short review of the old bindings and add a few remaining recipes from my dired.el.

Old stuff

  • Binding r to dired-start-process is covered here.
  • Binding e to ediff-files is mentioned here.
  • Binding z to dired-get-size is covered here.
  • Binding ` to dired-open-term is covered here.

Jump to a file with ido

(define-key dired-mode-map "i" 'ido-find-file)

I use this one quite frequently: i is somehow mnemonic to C-i, which means completion. Remember that you can select the current candidate with C-m and the current text (usually to create a new file) with C-j.

Move up and down

(define-key dired-mode-map "j" 'dired-next-line)
(define-key dired-mode-map "k" 'dired-previous-line)

As I've mentioned before, this is my standard recipe for all modes that don't self-insert.

Flag garbage files

(define-key dired-mode-map (kbd "%^") 'dired-flag-garbage-files)

Huh, I always thought this was the default binding. I have no idea where this came from, but I use this plus x to get rid of the garbage produced by a LaTeX run:

(setq dired-garbage-files-regexp
      "\\.idx\\|\\.run\\.xml$\\|\\.bbl$\\|\\.bcf$\\|.blg$\\|-blx.bib$\\|.nav$\\|.snm$\\|.out$\\|.synctex.gz$\\|\\(?:\\.\\(?:aux\\|bak\\|dvi\\|log\\|orig\\|rej\\|toc\\|pyg\\)\\)\\'")

Emacs' adaptation of find

(define-key dired-mode-map "F" 'find-name-dired)

This little function is essential if you want to do perform some operation on all files in the current directory and its sub directories that match a pattern. Basically the same thing that you would do with the UNIX find, just better.

Ignore unimportant files

(define-key dired-mode-map (kbd "M-o") 'dired-omit-mode)

This will toggle the display of unimportant files, like:

(setq dired-omit-files "\\(?:.*\\.\\(?:aux\\|log\\|synctex\\.gz\\|run\\.xml\\|bcf\\|am\\|in\\)\\'\\)\\|^\\.\\|-blx\\.bib")

Move to the parent directory

(define-key dired-mode-map "a"
    (lambda ()
      (interactive)
      (find-alternate-file "..")))

There probably is a default function that does this. I've been using this one for years, probably because it reuses the current dired buffer of opening the parent directory.

Outro

Phew, that's a lot of bindings. I don't necessarily encourage you to use the same bindings as me; I just want to bring your attention to some of these functions, so that you can work them into your workflow. If you notice that I'm using some obsolete stuff, do let me know, I'm always looking to improve.