Can some one walk me through the explicit key chords to:
- Select/open all of the filtered files in the minibuffer.
Ivy does not provide a built-in way to act on all completion candidates at once.
The closest you can come in general is by enabling "calling" via C-oc (requires the ivy-hydra
package; see (ivy) Hydra in the minibuffer
). When "calling" is enabled, merely navigating to a candidate (e.g. via C-n/C-p) automatically selects that candidate as well. The effect is a bit like scrolling through the list of candidates with an automatically updated preview.
Otherwise, you will have to write your own command. Here is an example of how you could open all current file/directory candidates:
(defun my-ivy-find-files ()
"Visit all current completion candidates as files.
Switch to the buffer visiting the first candidate."
(interactive)
(let ((files (all-completions "" (ivy-state-collection ivy-last))))
(mapc #'find-file-noselect (cdr files))
(find-file (car files)))
(minibuffer-keyboard-quit))
You can, of course, modify the logic (e.g. filter by regular file/directory) and key binding:
(with-eval-after-load 'ivy
(define-key ivy-minibuffer-map (kbd "C-c f") #'my-ivy-find-files))
- Select/open some of the filtered files in the minibuffer.
(ivy) Key bindings for single selection action then exit minibuffer
describes how to act on only a single candidate:
- C-m/RET Exits with the currently selected file/directory.
- C-j Same as C-m, but will descend into directories instead of opening them in Dired.
(ivy) Key bindings for multiple selections and actions keep minibuffer open
describes how to act on multiple candidates without exiting the completion session:
- C-M-m Opens the currently selected file/directory but keeps the completion session active.
- C-M-n Same as C-nC-M-m.
- C-M-p Same as C-pC-M-m.
So, if, for example, you wanted to open the 1st, 3rd and 4th candidates, you could type:
C-M-mM-2C-M-nC-M-nRET
- If possible, do the same things in a Dired window (not sure if Ivy applies there?).
Ivy applies wherever completion does. For example, when ivy-mode
is enabled, typing j (dired-goto-file
) in a Dired buffer will complete the file/directory to jump to with Ivy completion.
Otherwise, Dired and Dired-X provide various ways to operate on subsets of the current directory listing.
The simplest way to open multiple files at once is probably by using the command dired-do-find-marked-files
from Dired-X, which is bound to F by default; see (dired-x) Advanced Mark Commands
for information on this command and (dired-x) Installation
for how to enable the built-in Dired-X extensions to Dired.
When Dired-X is loaded, you just need to mark the files you're interested in before typing F. See (dired) Flagging Many Files
, (dired) Marks vs Flags
and (dired-x) Special Marking Function
for information on the various available types of marking commands.
See also https://stackoverflow.com/q/1110118/3084001.