[deleted] · 2022-08-03 19:54
[deleted]
CulturMultur · 2022-08-03 20:51
- searching in directory by filename
`C-x p f`, `M-x project-find-file`
- search by filename through previously opened files
`M-x consult-recent-file`, I bound it to `s-r`
- search through buffer list by file name
`M-x consult-buffer`, I bound it to `C-x b`
- search in directory for string in files
I use three:
* `M-x rg-dwim` (from rg.el), bound it to `M-s s`
* `M-x deadgrep`, bound it to `M-s d`
* `M-x consult-ripgrep-project`, bound it to `M-s f`
- search through current buffer by string
`M-s o`, `M-x occur`
- search through all open buffers by string
Don't know, never needed that.
- search through directory for word under cursor)
Don't know, never needed that.
> and having a preview while doing all of this.
I found that I mostly *don't* want to have preview, so by selecting items using `C-n` and `C-p` there is no preview. If I need preview, use up and down arrow keys, then the thing under cursor will be previewed:
(use-package consult
:config
(setq consult-preview-key (list (kbd "<down>")
(kbd "<up>")
(kbd "`")
(kbd "\\"))
consult-find-command "fd --color=never --full-path ARG OPTS"))
For fuzzy-finding directories I found in notes that I tried [https://github.com/karthink/consult-dir](https://github.com/karthink/consult-dir) but wasn't satisfied with it so don't use it.
jakelstein · 2022-08-03 20:52
thank you for you reply, looking this over now.
CulturMultur · 2022-08-03 21:05
consult-preview-key configured in such a way, so by `C-n` and `C-p` I select an item, if needed preview, press `\`. Pressing`up`and`down` will move the cursor and preview it at the same time. I almost never use those by the way, found that it has been configured as it just now.
karthink · 2022-08-03 21:14
In addition to u/CulturMultur's suggestions,
- search through all open buffers by string:
The built-in method is to use ibuffer, mark the buffers you want to search (or mark all with `t`) and call `ibuffer-do-isearch`. Or run `multi-isearch-buffers`.
The "modern" way to do it would be to call `consult-line-multi`: this searches all buffers of the current project by default. With a prefix argument this searches all open buffers.
- search through directory for word under cursor:
The closest thing you could do is call `consult-grep` or `consult-ripgrep` and press `M-n`. This should insert the symbol at your cursor into the search prompt. You can write a little command to do this automatically:
(defun consult-grep-at-point () (interactive)
(consult-grep default-directory (thing-at-point 'sexp)))
JDRiverRun · 2022-08-04 02:52
>search through directory for word under cursor
I use embark-act (C-,) followed by consult-ripgrep (super-f) (it searches the entire project and is frighteningly fast). I then add any additional filtering (after another # marker), then sometimes embark-export it to a grep buffer for posterity. Can even then edit all those lines together at once with wgrep.
**Summarizing**:
**Packages**: consult, embark, wgrep (+ vertico if you'd like a nice UI for looking at candidates).
**Steps**:
1. C-, (embark-act) -> word or symbol at point is highlighted
2. super-f (consult-ripgrep) -> search happens and is asynchronously updated
3. \#some filtering terms \[a-k\]{3,} -> lines get filtered dynamically/instantly
4. embark-export (super-e for me) -> current lines sent to a grep buffer
5. C-c C-p to enable wgrep -> can now edit the grep buffer
6. Edit words across (potentially) dozens of files (using multiple cursors, search and replace, etc.)
7. C-c C-c to commit -> files are updated.
JDRiverRun · 2022-08-04 02:57
>search by filename through previously opened files
search through buffer list by file name
consult-buffer gives you both of these at the same time (+ project files too) and gives preview. You can narrow to just one category as well.