15

I want to mark all the files in the current dired buffer. Is there a command for this? Not including . and ...

My use case is hardlinking all the files in a directory and I always reach for M which is change mode. I can remove all marks with either (?) U unmark-all-marks or M-DEL unmark-all-files, and it would seem normal to have the opposite.

salotz
  • 1,400
  • 11
  • 21

2 Answers2

23

U (if necessary) followed by t

  • dired-unmark-all-marks
  • dired-toggle-marks
phils
  • 50,977
  • 3
  • 79
  • 122
  • 9
    There is also the more explicit option * s (dired-mark-subdir-files), now with 100% more key presses! – Basil Oct 18 '17 at 21:24
  • An excellent point -- particularly when multiple sub-directories have been inserted into the buffer. – phils Oct 18 '17 at 21:48
10

@phils provided the answer (which should be accepted, IMO).

If you use library Dired+ then you can also do what you ask in some other ways.

In particular, commands, such as H (dired-do-hardlink), that normally act on the marked files and directories (or on the N next such) let you use a special prefix argument to act on all of the displayed files and dirs, regardless of which ones are marked.

This can be convenient when you have a set of markings that you don't want to change just to be able to issue a one-off command that acts on all files.

These are the special prefix arguments that provide this Dired+ feature:

  • C-u C-u: all files listed - no directories (including . and ..)
  • C-u C-u C-u: all files and directories listed except . and ..
  • C-u C-u C-u C-u: all files and directories listed (including . and ..)

(As usual, a numeric prefix arg N acts on the next N files and dirs (or the previous N if N is negative, and any other prefix arg means act on just the file or dir of the current line.)

So in your case, if you want to hard-link all of the files and directories except for . and .. then you could use C-u C-u C-u H. And if you didn't want to hard-link any directories then you could use C-u C-u H.

Drew
  • 77,472
  • 10
  • 114
  • 243