Hot answers tagged

117 votes
Accepted

Edit file with super-user rights

Use C-x C-f and type out /su::/etc/hostname or /sudo::/etc/hostname as applicable. This uses the TRAMP package, which is distributed with Emacs. This package provides access to remote files, and more ...
user avatar
  • 2,167
93 votes
Accepted

How to quickly copy/move file in Emacs Dired?

From the documentation: dired-dwim-target is a variable defined in `dired.el'. Its value is nil Documentation: If non-nil, Dired tries to guess a default target directory. This means: if ...
user avatar
  • 6,091
37 votes
Accepted

Close all dired buffers

You could do the following: M-x ibuffer * / to mark buffers in dired mode. D to delete them.
user avatar
35 votes
Accepted

Current path in Dired or Dired+ to clipboard

Move the cursor to the directory header line (where the directory is shown - e.g., use M-<), then hit w. That copies the directory name to the kill ring. (w copies any file name from Dired, and it ...
user avatar
  • 70.3k
30 votes
Accepted

Is there a way to use query-replace from grep/ack/ag output modes?

@Malabarba mentioned the use of wgrep package for editing grep/ack/ag results. I would like to write a detailed walk-through of how I use the ag package and wgrep-ag packages to achieve editing of '...
user avatar
  • 24.3k
25 votes
Accepted

Tree-based directory browser?

Additionally you can use dired-subtree from dired-hacks repo. Here you have short demo and screenshot from my setup where I press i to drill down folder and ; to go back.: (define-key dired-mode-...
user avatar
  • 2,325
25 votes

Tree-based directory browser?

There are a couple of options for this. You can check out dirtree, which is based on dired. There is also an emacs port of vim's NERDTree called neotree. Both are excellent packages, though I tend ...
user avatar
  • 381
24 votes
Accepted

Tramp/Dired transfers files inline over ssh instead of using scp externaly

When you are saying "I am using tramp via ssh" I suppose you open a file like /ssh:host:/path/to/file. This is supposed to use always the ssh method. If you want to use the scp method, you shall use /...
user avatar
21 votes
Accepted

Programmatically insert files into Dired buffer

C-h f dired tells you the answer. Just pass to dired, as the DIRNAME argument, a list that has as its car the Dired buffer name you want (any string) and as cdr the list of file names you want listed ...
user avatar
  • 70.3k
20 votes
Accepted

How to mark all files in the current dired directory?

U (if necessary) followed by t dired-unmark-all-marks dired-toggle-marks
user avatar
  • 43.9k
18 votes
Accepted

Recursively open files matching regexp in marked directories

Try this: C-u C-x d This let's you enter arguments for how Dired should list files. By default it says -al at the prompt. Add R to that, ending up with -alR. Type RET. Select/type a directory and ...
user avatar
18 votes
Accepted

How to set emacs as the default file manager?

Dependent on your desktop environment the method to set a default application may differ. That said, many desktop environments respect the associations in ~/.local/share/applications/mimeapps.list, ...
user avatar
  • 5,216
17 votes
Accepted

Dired. First show list of folders

External ls GNU's ls has an option --group-directories-first, and you can control the list of options passed to ls by dired with the variable dired-listing-switches (assuming that you haven't already ...
user avatar
  • 1,911
16 votes

Tree-based directory browser?

Have you ever tried Emacs' M-x speedbar? :-) before installing some new package I'd try an inbuilt solution... Update 2020-01-10 Actually I'm using now dired-sidebar which is available via Melpa.
user avatar
15 votes

Is there a way to use query-replace from grep/ack/ag output modes?

What I would like to do is to either quickly build a dired buffer from existing grep output [...], or transform grep output into a list of buffers for multi-occur [...]. You don't need to convert the ...
user avatar
  • 22.4k
15 votes
Accepted

how to deal with ZIP archives in DIRED?

emacs 25.x The emacs 25.1 release will have in-built support for handling different kinds of archives from within dired. Below is the relevant excerpt from the NEWS file (C-h C-n). +++ *** The ...
user avatar
  • 24.3k
15 votes
Accepted

Finding files by names

Wildcard Use M-x find-name-dired to get files according to a wildcard. Example Find all files with suffix "org" in directory "~/org/". Enter the following M-x find-name-dired ~/org *org and ...
user avatar
  • 2,646
15 votes
Accepted

How to only show the file/directory column in a Dired buffer

Assuming this question is about dired (the Emacs directory editor mode), there is no simple built-in way to rearrange the columns. Dired is presenting the output of an ls command so you can customize ...
user avatar
  • 19.4k
14 votes
Accepted

Sort file names (numbered) in dired

Here's my config: (setq dired-listing-switches "-laGh1v --group-directories-first") The relevant part is -1v.
user avatar
  • 13.6k
13 votes

Edit file with super-user rights

Use find-file with tramp. At the prompt /sudo::/etc/ssh/ssh_config will use sudo and a subshell to open that file with root privileges. When sudo is first used it will prompt for a password, but until ...
user avatar
  • 4,004
13 votes

Close all dired buffers

Instead of add another function to kill all dired buffers, I suggest you take advantage of filter groups in ibuffer, it allow you to group buffer by many condition. Here is a example to set filter ...
user avatar
  • 957
13 votes
Accepted

How to use Dired marked files as arguments to arbitrary Emacs Lisp functions?

Just use function dired-get-marked-files. It gives you a list of the marked file and directory names. And then just use funcall or apply to pass them to a function. (You can also use w in Dired to ...
user avatar
  • 70.3k
13 votes
Accepted

How to stop dired printing "Reverting buffer ..."

Customize option auto-revert-verbose to nil. C-h v tells you this: auto-revert-verbose is a variable defined in autorevert.el. Its value is t Documentation: When nil, Auto-Revert Mode does not ...
user avatar
  • 70.3k
13 votes
Accepted

How to rename a file with dired with the current file name as default?

Pressing R in dired queries the new file name in the minibuffer. There you can access the current file name by pressing the ↓ button. Note that this is a general convention when querying ...
user avatar
  • 30.5k
12 votes
Accepted

Dired as an FTP client

Yes, you can do that. You don't need to (explicitly) use FTP. Just use C in Dired to copy from one directory to the other. You can copy in either direction: from local to remote or remote to local. ...
user avatar
  • 70.3k
12 votes
Accepted

How can I create a dired buffer listing all open files?

The dired command accepts a list of file-names as argument. Just create one and pass to it: (dired (cons "Open Files" (sort (remove nil (mapcar #'buffer-file-name (buffer-list))) #'string&...
user avatar
  • 22.4k
12 votes
Accepted

How to avoid typing "space" after "^" for moving up in directory in dired?

With your keyboard setup, the key ^ is most probably a "dead key". It is a key meant to be used in conjunction with another one, in order to produce another character. In this case, it is meant to ...
user avatar
  • 3,361
12 votes

Simple ways to copy/paste files and directories between dired buffers

You can do the following in vanilla Dired (no 3rd-party library needed): Go first to a Dired buffer that lists the target directory. With the cursor on the directory header line for a listing of the ...
user avatar
  • 70.3k

Only top scored, non community-wiki answers of a minimum length are eligible