The logical way should be C-u D to delete selected files permanently. How can we do that?

  • 1
    They are normally deleted permanently, do you maybe have delete-by-moving-to-trash set to t? If so, the way you suggest seems to be the way to go, at least the manual says so: gnu.org/software/emacs/manual/html_node/emacs/…
    – wvxvw
    Commented Sep 29, 2015 at 14:02
  • 1
    @wvxvw: No, C-u (the way suggested by the OP) does not have that effect. (The manual page you cite does describe delete-by-moving-to-trash, however.)
    – Drew
    Commented Sep 29, 2015 at 15:21
  • @Drew it also says: "Supplying a prefix argument to M-x delete-file or M-x delete-directory makes them delete outright, instead of using the Trash, regardless of delete-by-moving-to-trash." I understand that C-u would supply prefix argument, but maybe you could try other ways of supplying the argument?
    – wvxvw
    Commented Sep 29, 2015 at 17:24
  • @wvxvw: Yes, but D is not bound to either of those commands. That's the point. D is bound (by default) to dired-do-delete. Like the other dired-do-* commands, a prefix arg for dired-do-delete is used numerically, to perform the action on the next N files.
    – Drew
    Commented Sep 29, 2015 at 17:46
  • 1
    @wvxvw: FWIW, Dired+ has a command diredp-delete-this-file, which is bound to C-k and to the delete key (aka <delete>). I've just redefined it to use delete-file instead of dired-do-delete. HTH.
    – Drew
    Commented Sep 29, 2015 at 21:14

2 Answers 2


C-u D deletes the next 4 files (or moves them to the trash bin, if delete-by-moving-to-trash is non-nil).

If you want to delete files permanently, then set delete-by-moving-to-trash to nil. Then using D deletes the next N files (default 1), and d flags them for deletion by x.

  • Is there another way to temporarily delete selected file permanently? I think few people ever uses C-u D that way ( Do you count how many files to delete every time?), maybe replace the definition for D to do permanent delete with a prefix argument.
    – godblessfq
    Commented Sep 29, 2015 at 15:26
  • 1
    No idea what "temporarily delete selected file permanently" means. Temporarily? Permanently? D, with no prefix arg, deletes the file named on the current line: the prefix arg is implicitly 1, so 1 file is deleted. Deletion is permanent or just a move to the trash bin according to option delete-by-moving-to-trash, as mentioned.
    – Drew
    Commented Sep 29, 2015 at 15:34
  • 2
    If some people use C-u D to override a non-nil value of delete-by-moving-to-trash and thus delete the file permanently, then they have bound D to a different command, or they have redefined or advised command dired-do-delete, the default binding of D.
    – Drew
    Commented Sep 29, 2015 at 15:36

To follow-up from Drew's answer, I use the following function now:

(defun dired-do-delete-skip-trash (&optional arg)
  (interactive "P")
  (let ((delete-by-moving-to-trash nil))
    (dired-do-delete arg)))

I don't have this bound to a key, for safety reasons, but I can delete files skipping trash using M-x if absolutely needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.