When I use swiper to search inside a buffer I can use multiple search words separated by a blank space. This works.

But I also want that behaviour when search for a file (C-x f), a variable or function (C-h f or C-h v) or via M-x (what is this?) or finding a org-roam node.

I have cousel and ivy here and not sure which one of that packages is relevant for a the needed feature.

  • Enable ivy-mode and counsel-mode.
    – aadcg
    Nov 13 '21 at 22:24

If you use Icicles then you can:

  1. Match any number of search patterns (e.g. words, literal strings, regexps) during completion. So you can use that to match file names with C-x C-f, function names with C-h f, etc.

  2. Match not only file names this way (i.e., with multiple search patterns) but also, or instead, file contents. In Icicle minor mode C-x C-f is bound to the multi-completion command icicle-file, which lets you match either file name or file contents, or both, any number of times (e.g. with different patterns). C-h f icicle-file tells you this:

C-x C-f runs the command icicle-file (found in icicle-mode-map), which is an interactive compiled Lisp function in icicles-cmd1.el.

It is bound to menu-bar file icicles icicle-file, open, C-x C-f, menu-bar file new-file.

(icicle-file ARG)

Visit a file or directory.

  • With no prefix argument, use relative file names (icicle-find-file).
  • With a prefix argument, use absolute file names (icicle-find-file-absolute).
  • With a negative prefix arg, you can choose also by date: Completion candidates include the last modification date.

All of these commands let you search file content, as well as file names (unless you use an Emacs version prior to 23). See icicle-find-file and icicle-find-file-absolute for more information.

Note that when you use a prefix arg, completion matches candidates as ordinary strings. It knows nothing of file names per se. In particular, you cannot use remote file-name syntax if you use a prefix argument.

If you use a prefix arg when you act on a completion candidate, then you visit the file or dir in read-only mode. This includes when you act on all candidates using C-!: precede the C-! with a prefix arg. This does not apply to the final candidate chosen (using RET or mouse-2) - a prefix arg has no effect for that.

During completion (* means this requires library Bookmark+), you can use the following keys:

  • C-c C-d - change the `default-directory' (with a prefix arg)
  • C-c + - create a new directory
  • C-backspace - go up one directory level
  • M-| - open Dired on the currently matching file names
  • S-delete - delete candidate file or (empty) dir
  • * C-x C-t * - narrow to files with all of the tags you specify
  • * C-x C-t + - narrow to files with some of the tags you specify
  • * C-x C-t % * - narrow to files with all tags matching a regexp
  • * C-x C-t % + - narrow to files with some tags matching a regexp
  • * C-x a + - add tags to current candidate
  • * C-x a - - remove tags from current candidate
  • * C-x m - access file bookmarks (not just autofiles)

By default, Icicle mode remaps all key sequences that are normally bound to find-file to icicle-file. If you do not want this remapping, then customize option icicle-top-level-key-bindings.

For more info about icicle-file and other file-accessing commands see Icicles - File-Name Input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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