2

Under most operations, when I open a file with C-x C-f Ivy pops up my narrowing list at the bottom and its great.

However, I have a current situation when I'd like to open a file on a remote host in a directory that has 60,000 files in it. So when I C-x C-f into that directory over tramp, it takes an awfully long time until I can find the file I am looking for. Sometimes, though I know what the file name is and I'd just like to type it and not have Ivy butt in so that I can get on with it. How would I bet go about doing this?

  • 1
    No: ivy hooks into completing-read. – Fran Burstall May 21 at 8:00
  • 1
    You can toggle ivy with M-x ivy-mode and then do as @phils suggested and do M-x find-file. – Fran Burstall May 21 at 8:03
  • Or indeed C-x C-f, I expect. I've deleted my erroneous suggestion in any case. – phils May 21 at 9:05
  • 1
    I have to turn ivy-mode off in order to edit TRAMP paths to add multiple hops. Because of key bindings set to use counsel I cannot use C-x C-f because counsel butts in and calls ivy-completing-read! Instead, you have to do M-x find-file after disabling ivy-mode – gregoryg May 21 at 20:58
  • indeed this does work, calling M-x find-file after disabling ivy-mode. Perhaps not ideal, but it works – Vince W. May 22 at 1:11
2

In default Ivy configurations, C-x C-f is bound to counsel-find-file which will invoke ivy-completing-read even if global ivy-mode is turned off!

Rather than going through the clumsy steps of disabling Ivy, calling the non-Counsel find-file, then turning Ivy back on, I have implemented this solution.

In the given use case of many files, you can enter a portion of the file name, then use TAB to get completion on the matching set.

(defun gjg/find-file-no-ivy ()
  (interactive)
  (let ((ivy-state ivy-mode))
    (ivy-mode -1)
    (call-interactively 'find-file)
    (ivy-mode ivy-state)))

(global-set-key (kbd "C-x F") 'gjg/find-file-no-ivy) ; steals key from set-fill-column

The function restores the state of ivy-mode. Bind to any key that works for you!

| improve this answer | |

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.