When i do C-x C-f to create a new file in the directory A, if emacs finds another file in another directory (say B) with exact same name, in the mini-buffer it changes the path to the other existing file (forcing me to open the old file instead of letting me create my new file). How can i disable this annoying thing?

Update It is because of the ido-vertical mode which i have in my init.el:

;;; ido vertical
(require 'ido-vertical-mode)
(ido-mode 1)
(ido-vertical-mode 1)
(setq ido-vertical-define-keys 'C-n-and-C-p-only)
  • 4
    This is not the standard Emacs behavior. Please provide a step-by-step recipe to reproduce it, preferably starting from emacs -Q (no init file). If you don't know what causes it then bisect your init file to find out. The question so far is unclear, and so risks being closed. – Drew Feb 26 '18 at 3:47
  • 1
    Folks are trying to guess what you mean - Ivy? Ido? Please clarify the question or delete it. Thx. – Drew Feb 26 '18 at 16:09
  • 2
    There's a way to turn on ido just for switching buffers, like this: github.com/DoMiNeLa10/.emacs.d/blob/… – user12563 Feb 26 '18 at 16:32

Asuming that C-x C-f is bound to ido-find-file you drop back to the non-Ido version by typing C-x C-f again or just C-f. This will allow you to create the file you want without Ido interfence.


This isn't the default behavior of Emacs, so it's likely that you're using a package that modifies it. I'm going to guess that you're using ido-mode. I occasionally get annoyed by this same aspect of ido-mode, but I don't think there's really a fix for it. If the search is taking long enough, you can hit C-g to cancel it, but if it's already finished the search that will cancel the ido-find-file command entirely. Another work around is to hit C-f again before it searches, this will drop you back to the default Emacs find-file.

Another thing I've started doing is using projectile-mode. This has a command to open another file in the same project (projectile-find-file, bound to C-c p f by default) which enumerates all of the files in the project before asking you to select one. You still get ido-mode's matching behavior, but since it has all the files in the project already it'll do less searching of unrelated projects. Of course, that requires that your files be in a "project" as Projectile defines it. On the other hand it treats any version-control repository as a project, which is very convenient.

And of course you have the option of disabling ido-mode entirely; just comment it out in your init file.

  • 1
    He could also be using ivy, in which case he can use the test he has input, without matching another existing entry, by using Control-Alt-j. – InHarmsWay Feb 26 '18 at 12:34
  • 1
    If it's ido-mode then maybe setting ido-auto-merge-work-directories-length to -1 would help? I have that setting in my init file with the comment don't jump to some other directory when I mistype a filename. – npostavs Feb 26 '18 at 13:02
  • @npostavs - i'm stuck with the same problem and it's help – rootatdarkstar Jan 6 '19 at 15:05
  • Just type C-x C-f two times in a row. This will call the non Ido version of find-file. – FredrikHedman Feb 5 '19 at 9:13

You can enable ido-mode only for buffer switching commands, here's the relevant part of the docstring for that function:

However, if ARG arg equals ‘files’, remap only commands for files, or if it equals ‘buffers’, remap only commands for buffer switching.

You can pass the symbol buffers to ido-mode to enable it only for buffer switching like this:

(ido-mode 'buffers)

Your Answer

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