Can I disable ivy completion for a single command while in minibuffer?

For example I am in folder ~/code/study/ . If I open find file and autocomplete with Ivy I will see

Find file: ~/code/study/


and I want, in a single jump go to ~/other/code/study. Since I have ivy-mode to autocomplete I cannot move my cursor to the first / and just type other there. This is being a pain for some things. Can I somehow edit the first part of a completion or even disable completion temporarily just for this command?

Thanks a lot!

6 Answers 6


I think what you're looking for is C-M-j (ivy-immediate-done) in the mini buffer. This function is described as follows in the Ivy manual:

Exits with the current input instead of the current candidate (like other commands).

This is useful e.g. when you call find-file to create a new file, but the desired name matches an existing file. In that case, using C-j would select that existing file, which isn't what you want—use this command instead.

  • 1
    But how can I get my cursor to ~/<here>/code/study to edit and apply the immediate-done? May 18, 2017 at 7:26
  • I don't think you can with C-M-j, but it is one way of disabling completion.
    – tirocinium
    May 18, 2017 at 12:58

There are multiple approaches to file navigation that apply here.

Just to rephrase your statement:

switch from ~/code/study to ~/other/code/study

  1. Easiest and most consistent: use ~ to switch to ~/ and navigate from there.
  2. Assume you visited ~/code/study once before in the current Emacs session. Press C-r to access all files you visited before. You can erase the file part with C-k.
  3. Assume you have ~/code/study as a bookmark or in recentf. Press M-o b to get completion for those.
  4. Assume you are in the dired buffer of ~/code/study. Press 0w to copy the current path. Press C-x C-f C-y: you can edit the yank in the minibuffer.

Edit: one more approach

With the most recent commit, you can press C-M-o w C-y to edit the full path in the minibuffer. If you use this a lot, counsel-find-file-map is available to bind this combination to something shorter.


You can edit the filename root during completion by typing DEL or <backspace>. Each such keypress switches to the parent directory.

See section File Name Completion of the Ivy User Manual for more information. In particular, you may be interested in the the special handling of slashes and tildes - entering two slashes during any part of the completion will change the directory to the root directory (/) and similarly a tilde will switch to your home directory.

See also customisable variable ivy-on-del-error-function.

  • 1
    If I do that I'd have "~/code/study" then backspace "~/code/" then "~" code. And I'd had to start again with Dropbox/code/study. I'd like to avoid that repeat of code/study. May 18, 2017 at 7:25

As of 2022-02-19, the File Name Completion section of the Ivy manual, that @Basil mentioned earlier, now includes C-M-y bound by default to ivy-insert-current-full. That keybinding allows you to directly edit that path, without requiring further Ivy/Counsel customization.


Open up a directory, say /tmp/dir1 and notice that the /tmp/dir1 text is not truly editable (see Rafa de Castro's comment caution about DEL or BACKSPACE deleting parent directory text that is the very text that is desired to be edited):

noticing the non-editable text

Typing C-M-y pastes the /tmp/dir1 path into the editable text area of the minibuffer:

after typing C-M-y

Your arrow key bindings are now active as normal and you can edit it:

edited text area

Update 2022-09-15 08:59:22 for clearing initial input before insertion in CTRL+SHIFT+y

An annoyance, slightly related to Mike Crowes comment on his question, is when you have typed in some input characters before typing CTRL+SHIFT+y, the directory path is appended to that path, instead of overwriting it with that new directory path. This is annoying in the majority of cases whereby the users intent is to edit that directory path somewhere in the middle of that long path, type RETURN, only to be baffled as to why Emacs shows some non-existent path with that initial input in front of the path.

Below is my workaround for that annoyance using advice-add (advice):

enter link description here

  (defun bg-ivy-insert-current-full-clear-input-before-insert ()
    "Clear the input before calling `ivy-insert-current-full'."
    ;; Use (line-beginning-position) instead of (point-min) because of text properties in use that inhibit motion:
    (delete-region (line-beginning-position) (point-max)))

  (advice-add 'ivy-insert-current-full :before #'bg-ivy-insert-current-full-clear-input-before-insert)

You can still get the default find-file behavior if you do

(defun default-find-file ()
   (let  ((completing-read-function 'completing-read-default))
     (call-interactively 'find-file) ))

You can paste the complete path (again) then edit:

C-M-y (ivy-insert-current-full)

Now the minibuffer looks like this:

Find file: ~/code/study/~/code/study/

which you now can edit to

Find file: ~/code/study/~/other/code/study/

BTW: This is the only way I found if you want to modify the access to a remote dir:

Find file: /userA@remoteHost:/somedir

If you want to change userA to userB ivy doesn't allow editing that part at all.

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.