6

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?

7
  • 1
    No: ivy hooks into completing-read. Commented May 21, 2020 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. Commented May 21, 2020 at 8:03
  • Or indeed C-x C-f, I expect. I've deleted my erroneous suggestion in any case.
    – phils
    Commented May 21, 2020 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
    Commented May 21, 2020 at 20:58
  • 1
    @gregoryg, I haven't had a chance to come back to it yet. In something of an ebb with that work
    – Vince W.
    Commented Aug 27, 2020 at 14:57

1 Answer 1

5

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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