5

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?

Vince W.
  • 395
  • 2
  • 11
  • 1
    No: `ivy` hooks into `completing-read`. – Fran Burstall May 21 '20 at 08: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 '20 at 08:03
  • Or indeed `C-x C-f`, I expect. I've deleted my erroneous suggestion in any case. – phils May 21 '20 at 09: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 '20 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 '20 at 01:11
  • Did you find a good way to work in that huge directory of files? – gregoryg Jul 14 '20 at 18:12
  • 1
    @gregoryg, I haven't had a chance to come back to it yet. In something of an ebb with that work – Vince W. Aug 27 '20 at 14:57

1 Answers1

4

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!

gregoryg
  • 915
  • 6
  • 8