I'd like to continue using fuzzy matching with Ivy except in swiper.
The variable that determines which "regexp builder", as Ivy refers to these functions, is used for which collection function is ivy-re-builders-alist:
ivy-re-builders-alist is a variable defined in ‘ivy.el’.
Its value is ((t . ivy--regex-plus))
An alist of regex building ...
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
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 ...
The command counsel-M-x does this for you:
(ivy) Global key bindings recommends you remap M-x (execute-extended-command) to counsel-M-x in order to avail of its increased Ivy-ness, e.g. via
(when (commandp 'counsel-M-x)
(global-set-key [remap execute-extended-command] #'counsel-M-x))
Alternatively (and more simply), you can just enable counsel-mode and ...
What you want can be achieved by adding a new source to completion-at-point-functions. This isn't specific to ivy, but ivy makes use of it:
(defun dabbrev-complation-at-point ()
(let* ((abbrev (dabbrev--abbrev-at-point))
(candidates (dabbrev--find-all-expansions abbrev t))
You can use C-M-j which calls ivy-immediate-done to force the output to be exactly what you typed instead of having it complete to the the nearest match
This and more information can be found in the ivy manual ivy-manual
What would be more convenient is for me to do so via counsel-find-file, navigate to the file path and then insert at the point in the current buffer (or some similar workflow with autocompletion) instead of actually opening the file.
Ivy provides a built-in way to do this. During Ivy completion you can invoke custom actions on the current candidate; see (...
There are multiple approaches to file navigation that apply here.
Just to rephrase your statement:
switch from ~/code/study to ~/other/code/study
Easiest and most consistent: use ~ to switch to ~/ and navigate from there.
Assume you visited ~/code/study once before in the current Emacs session. Press C-r to access all files you visited before. You can ...
When I'm opening a file I'd like . and .. to be omitted from the list of completion candidates.
This is what the user option ivy-extra-directories is for:
ivy-extra-directories is a variable defined in ‘ivy.el’.
Its value is ("../" "./")
Add this to the front of the list when completing file names.
Only "./" and "../" apply here. They ...
There are 2 cases. The name you want to create doesn't match anything in the completion list, or when it does.
When it doesn't, you can just type in the name and press enter.
If it does match, then pressing enter will get ivy to expand the name to the completion. Here you want to call ivy-immediate-done which is bound to C-M-j by default after you ...
I found something that seems to work OK upon initial testing: essentially rebind <tab> to pcomplete-std-complete, but since that function isn't interactive for some reason, you need to wrap it:
(define-key eshell-mode-map (kbd "<tab>")
(lambda () (interactive) (pcomplete-std-complete)))
The pcompete-std-complete tries to use the completions ...
For those users of an ivy/counsel persuasion, the command counsel-org-tag (added in v0.6 AFAICT) enables ivy-backed completion (including multiple selection and deselection) of org-mode tags:
counsel-org-tag is an interactive autoloaded compiled Lisp function in
Add or remove tags in org-mode.
In my configuration ...
When you invoke swiper press M-p to search for previously searched thing.
M-n will let you search for the word under cursor.
C-s will search for the next occurence.
UPD, thx @Basil
After you invoke the swiper press C-s to search for a previously searched string. Press C-s again to go to the next occurrence.
You can create a new Ivy action that opens the directory of a file name selection. It can be done with:
(defun my/ivy-open-dir-action (x)
(dired (or (file-name-directory x)
'(("d" my/ivy-open-dir-action "open in dired")))
To invoke it, you can search normally and ...
C-M-j (ivy-immediate-done) - exit with the current action, calling it on the current input instead of the current candidate. This is useful especially when creating new files or directories - often the input will match an existing file, which you don’t want to select.
Try M-j, which is bound to ivy-yank-word in the ivy minibuffer key map.
It's worth reading through the the ivy manual, either in Emacs or online. The relevant key bindings are discussed here: http://oremacs.com/swiper/#key-bindings-that-alter-the-minibuffer-input
The code in this answer is now part of Ivy: https://github.com/abo-abo/swiper/commit/ae438ff62fa3d9b98d899afc0e97c13be2148725
Within ivy-hydra, the m key is bound to the command ivy-toggle-fuzzy, which is hard-coded to toggle the variable ivy--regex-function between the regexp-building functions ivy--regex-fuzzy and ivy--regex-plus.
The ivy-hydra panel is ...
If you want to turn off regex matching in swiper, but keep it active elsewhere, add this to your user-init-file:
'((swiper . regexp-quote)
(t . ivy--regex-fuzzy)))
If you want to deactivate it just once, hit M-r in swiper.
Ivy already has an action bound to "k" for ivy-switch-buffer, but it just calls kill-buffer so it does not work on virtual buffers.
Based on what ido is doing, here's some code to replace the default ivy kill action with one that also handles virtual buffers by dropping them from the recentf list:
(defun my-ivy-kill-buffer (buf)
If it's not possible for helm, how about ivy/counsel/swiper?
Ivy is the library which Swiper search and Counsel convenience functions are backed by, so changing the way Ivy interprets its input affects the other two packages by extension.
IIUC, all helm commands (including helm-swoop, swiper-helm) have regex enabled by default for user input.
This is ...
Ivy provides a user option to control this behaviour. Quoth (ivy) Defcustoms (edit mine):
-- User Option: ivy-on-del-error-function
Specify what [to do] when ‘DEL’ (‘ivy-backward-delete-char’) throws.
The default behavior is to quit the completion after ‘DEL’ – a
handy key to invoke after mistakenly triggering a completion.
According to https://github.com/abo-abo/swiper/issues/648, it's simply
(setq ivy-virtual-abbreviate 'full)
It's not quite as nice as opened buffers (where only the differing part is shown), but good enough.
(I haven't found anything like that for ido though.)
In ivy, it can not to create directly a new file in a new folder
Emacs can do this regardless of whether ivy-mode is enabled, or whether you are using counsel-find-file. You will be prompted to create any non-existent parent directories when you try to write the buffer contents to a file (e.g. C-xC-s), or you can create them yourself via M-xmake-...
Thanks to this blogpost, I found a solution. The real tool that I was looking for was wgrep which does the multi-editing heavy lifting that I was missing. Here are the steps for using the Silver Searcher backend:
After you've found the search results, run C-c C-o (ivy-occur)
Toggle the edit flag of the buffer to enter wgrep mode: hit C-x C-...
Two ways to find a file name deep in a directory, without having to drill down:
SPC SPC counsel-file-jump lists all files below parent directory.
But first use SPC f f (counsel-find-file) to select a parent directory.
SPC f L (counsel-locate) lists all matching directory and file names from Linux root.
It's a bit tricky, since you can't call anything after read-from-minibuffer (called by ivy-read called by swiper) until it returns.
However, there's a visible function swiper--update-input-ivy that's called in post-command-hook. You can advice this function.
It could also be possible to advice ivy--exhibit (it's always in the minibuffer's post-command-hook), ...