Skip to content

Commit ce43b7a

Browse files
using-neovim: search-replace with grug-far
resolve: #77
1 parent fdf43c5 commit ce43b7a

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- dev: book configuration & make task for deploying to staging
3333
- dev: add scheduled stale issue & pull request check
3434
- intro: troubleshoot guide with examples
35+
- using-neovim: search-replace with grug-far
3536

3637
### Changed
3738
- ci: spell lychee & repository trufflehog linters warn only (false positives)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Grug Far
2+
3+
A very efficient search and replace tool using the external [ripgrep command](https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md) line tool.
4+
5+
++spc++ ++"s"++ is the search and replace menu
6+
7+
++"g"++ ++"?"++ for help menu in the Grug-far buffer
8+
9+
10+
!!! NOTE "Search and replace with Grug-Far"
11+
12+
++spc++ ++"s"++ ++"s"++ to search across the current workspace (project)
13+
14+
Enter a Search pattern, press ++esc++ and all occurrences across the project are shown
15+
16+
Enter a Replace pattern, press ++esc++ to see occurrences with their replacement
17+
18+
++comma++ ++"r"++ to replace all occurrences with the replace pattern
19+
20+
++comma++ ++"j"++ / ++"k"++ replace at current line & move to next / previous change
21+
22+
23+
24+
??? TIP "Search results in Quicklist"
25+
++comma++ ++"q"++ adds search results to quickfix list to edit occurrences with other Neovim tools
26+
27+
28+
## Search buffer
29+
30+
Enter patterns in the **Search** and **Replace** and the results are show in a diff below.
31+
32+
++tab++ and ++shift++ ++tab++ navigate between search buffer sections.
33+
34+
![Grug-Far Search buffer](https://github.com/practicalli/graphic-design/blob/live/editors/neovim/astronvim-5/neovim-search-grug-far-search-dark.png?raw=true){loading=lazy}
35+
36+
??? EXAMPLE "Usefull Ripgrep options for Grug-Far"
37+
- `-i/--ignore-case`: ignore case differences, e.g. `rg -i fast` matches `fast`, `fASt`, `FAST`, etc.
38+
- `-F/--fixed-strings`: Disable regular expression matching and treat the pattern as a literal string.
39+
- `-w/--word-regexp`: pattern matches are surrounded by word boundaries, e.g. `pattern` is `\b(?:pattern)\b`.
40+
- `-c/--count`: a count of total matched lines.
41+
- `-a/--text`: Search binary files as if they were plain text.
42+
- `-U/--multiline`: Permit matches to span multiple lines.
43+
- `-z/--search-zip`: Search compressed files (gzip, bzip2, lzma, xz, lz4, brotli, zstd). This is disabled by default.
44+
- `-C/--context`: Show the lines surrounding a match.
45+
- `-L/--follow`: Follow symbolic links while recursively searching.
46+
- `-M/--max-columns`: Limit the length of lines printed by ripgrep.
47+
48+
[All Ripgrep Options](https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#common-options)

docs/using-neovim/search-replace/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Neovim has several built-in commands to search for patterns in the current buffe
44

55
Additional tools that work across all the files in a project:
66

7-
- ++spc++ ++"s"++ ++"s"++ [search and replace commands using Spectre](#spectre)
8-
- ++spc++ ++"l"++ ++"r"++ to rename symbols using [Clojure LSP](/neovim/repl-driven-development/refactor-tools/)
7+
- ++spc++ ++"s"++ ++"s"++ search and replace using [Grug-far](grug-far.md)
8+
- ++spc++ ++"l"++ ++"r"++ to rename symbols using [Clojure LSP](/neovim/clojure-repl-workflow/refactor-tools/)
99

1010
> [:fontawesome-solid-book-open: multiple cursors](../multiple-cursors.md) for in-place editing within a buffer
1111

0 commit comments

Comments
 (0)