29 lines
1.3 KiB
Markdown
29 lines
1.3 KiB
Markdown
---
|
|
title: "custom ripgrep"
|
|
date: 2020-01-11T14:59:13+01:00
|
|
draft: false
|
|
snippet_types: ["vim", "search"]
|
|
---
|
|
|
|
In the past I used full plugin level text searching solutions the likes of
|
|
**:Rg**, **:Grep**, **:Ag** from the [vim grep plugin](https://github.com/yegappan/grep).
|
|
Recently I've found it faster and more customizable to just run **:term** do my searching
|
|
from there and then opening file under cursor in new split with **\<C-W>\<f>**. Doing the
|
|
searches directly in terminal builds more on all the tricks I've devolved outside of vim world.
|
|
However launching terminals all the time is also has it's pain points, so now I've come up with a
|
|
simple key mapping to run searches in a new scratch window without having to go full term.
|
|
|
|
yank the search term then **\<Leader>\<s>** pulls up a new scratch buffer with the search pre-filled
|
|
but with the ability to still edit and add further customisations.
|
|
```vim script
|
|
nnoremap <Leader>s :Sscratch<CR>:read ! rg -i <C-R>"
|
|
```
|
|
|
|
here I use the technique to search for all snippet files tagged with vim
|
|
|
|
{{< asciicast-with-caption id="293019" title="demo of using the jump list" >}}
|
|
|
|
plugins:
|
|
|
|
- [vim grep plugin](https://github.com/yegappan/grep)
|
|
- [scratch buffer plugin](https://github.com/vim-scripts/scratch.vim/blob/master/plugin/scratch.vim)
|