mirror of
https://github.com/wezm/wezm.net.git
synced 2024-12-19 02:39:54 +00:00
Add /technical/2016/09/ripgrep-with-vim
This commit is contained in:
parent
8b0f3895ce
commit
a5e25cb702
2 changed files with 62 additions and 0 deletions
47
content/technical/2016/09/ripgrep-with-vim.md
Normal file
47
content/technical/2016/09/ripgrep-with-vim.md
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
[ripgrep][rg] (`rg`) is a new text search tool by [Andrew Gallant][BurntSushi]:
|
||||||
|
|
||||||
|
> ripgrep combines the usability of [The Silver Searcher][ag] (an [ack] clone)
|
||||||
|
> with the raw performance of [GNU grep][grep]. ripgrep is fast, cross platform
|
||||||
|
> (with binaries available for Linux, Mac and Windows) and written in
|
||||||
|
> [Rust][rust].
|
||||||
|
|
||||||
|
[BurntSushi]: http://blog.burntsushi.net/about/
|
||||||
|
[ack]: http://beyondgrep.com/
|
||||||
|
[ag]: https://github.com/ggreer/the_silver_searcher
|
||||||
|
[grep]: https://www.gnu.org/software/grep/
|
||||||
|
[rg]: https://github.com/BurntSushi/ripgrep
|
||||||
|
[rgbench]: http://blog.burntsushi.net/ripgrep/
|
||||||
|
[rust]: https://www.rust-lang.org/
|
||||||
|
|
||||||
|
Andrew has written in [extensive detail on the benchmarking][rgbench] he did,
|
||||||
|
which shows `ripgrep` is one of the fastest and most correct tools of this
|
||||||
|
nature. To make use of `ripgrep` within vim here are a few options:
|
||||||
|
|
||||||
|
Set [grepprg](http://vimdoc.sourceforge.net/htmldoc/options.html#'grepprg'),
|
||||||
|
which is used by [:grep][colon-grep] to search a project and add the matches
|
||||||
|
the quickfix list:
|
||||||
|
|
||||||
|
if executable("rg")
|
||||||
|
set grepprg=rg\ --vimgrep\ --no-heading
|
||||||
|
set grepformat=%f:%l:%c:%m,%f:%l:%m
|
||||||
|
endif
|
||||||
|
|
||||||
|
[colon-grep]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:grep
|
||||||
|
|
||||||
|
For use with [ack.vim](https://github.com/mileszs/ack.vim) set `g:ackprg` as
|
||||||
|
follows. Now when you run `:Ack` it will use `rg` instead:
|
||||||
|
|
||||||
|
let g:ackprg = 'rg --vimgrep --no-heading'
|
||||||
|
|
||||||
|
One of my favourite plugins, [fzf.vim](https://github.com/junegunn/fzf.vim) has
|
||||||
|
built-in support for `ag`. I've created an [experimental fork][fork] that adds
|
||||||
|
support for `rg` to it. My fork adds the `:Rg` user command, which works the
|
||||||
|
same was as the existing `:Ag` command. To use my version of the plugin with
|
||||||
|
[vim-plug] add the following to your `.vimrc`:
|
||||||
|
|
||||||
|
Plug 'wezm/fzf.vim', { 'branch': 'rg' }
|
||||||
|
|
||||||
|
The line will be similar in Vundle or pathogen.
|
||||||
|
|
||||||
|
[fork]: https://github.com/wezm/fzf.vim/tree/rg
|
||||||
|
[vim-plug]: https://github.com/junegunn/vim-plug
|
15
content/technical/2016/09/ripgrep-with-vim.yaml
Normal file
15
content/technical/2016/09/ripgrep-with-vim.yaml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
title: Using ripgrep With Vim
|
||||||
|
extra: A few ways to use the ripgrep text search tool within vim.
|
||||||
|
kind: article
|
||||||
|
section: technical
|
||||||
|
created_at: 2016-09-28 13:46:00.000000000 +10:00
|
||||||
|
keywords:
|
||||||
|
- ack
|
||||||
|
- ag
|
||||||
|
- productivity
|
||||||
|
- ripgrep
|
||||||
|
- rust
|
||||||
|
- tools
|
||||||
|
- vim
|
||||||
|
short_url:
|
Loading…
Reference in a new issue