Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use inside vim? #425

Closed
Neats29 opened this issue Mar 30, 2017 · 12 comments
Closed

How to use inside vim? #425

Neats29 opened this issue Mar 30, 2017 · 12 comments

Comments

@Neats29
Copy link

Neats29 commented Mar 30, 2017

Thanks for building this, it's very cool. Quick question, I was wondering if you could please let me know or add to the readme how to integrate this with vim. At the very least I'm interested in 'search and replace' globally within a repository.

Thank you.

@FSMaxB
Copy link

FSMaxB commented Mar 30, 2017

You could ask mileszs/ack.vim for integration of rg.

@Neats29
Copy link
Author

Neats29 commented Mar 30, 2017

@FSMaxB but from reading the other issues, it seems like some people are using it inside vim already, so I thought there might be a way...

@Neats29
Copy link
Author

Neats29 commented Mar 30, 2017

My bad for not searching the internet first. There is this plugin: vim-ripgrep and this article for using with fzf :)

@BurntSushi
Copy link
Owner

Sounds like you got your answer.

I wouldn't be opposed to putting links to editor integrations in the README. But since I don't use any of them myself, I probably won't do it.

@ericandrewlewis
Copy link

I wouldn't be opposed to putting links to editor integrations in the README. But since I don't use any of them myself, I probably won't do it.

It took me a little to figure out how to do this. Can I open a PR with some suggested context setting for folks interested in this?

@BurntSushi
Copy link
Owner

@ericandrewlewis Yeah sure! Just put it toward the bottom of the README with the other questions. (At some point, I will split it out into a proper FAQ.)

@pirj
Copy link

pirj commented Apr 15, 2018

For the future researchers:

set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case

works great with no other configuration required.

I use this mapping to open the list of the files in location list:

nnoremap <Leader>g :silent lgrep<Space>

and further navigate it:

nnoremap <silent> [f :lprevious<CR>
nnoremap <silent> ]f :lnext<CR>

@dyng
Copy link

dyng commented Jul 21, 2019

If you don't mind using a plugin, It's my pleasure to recommend my plugin ctrlsf.vim which integrates rg out of the box, and supports asynchronous searching.

@jpesce
Copy link

jpesce commented Oct 1, 2020

For the future researchers:

set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case

works great with no other configuration required.

I use this mapping to open the list of the files in location list:

nnoremap <Leader>g :silent lgrep<Space>

and further navigate it:

nnoremap <silent> [f :lprevious<CR>
nnoremap <silent> ]f :lnext<CR>

As an addendum, since this issue comes up when searching for this in search engines.
Also set the format like so: set grepformat+=%f:%l:%c:%m
This will make the location list understand the output format better


11/01/2022: Updated grepformat — Thanks @craigmac!

@nyngwang
Copy link

For the future researchers:

set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case

works great with no other configuration required.

@pirj A noob question here: If this works, why do we need a plugin like vim-ripgrep?

@pirj
Copy link

pirj commented Jan 29, 2022

why do we need a plugin like vim-ripgrep?

At a glance, it offers match highlighting, and configuring quickfix window location.

@craigmac
Copy link

craigmac commented Nov 1, 2022

Also set the format like so: set grepformat=%f:%l:%c:%m,%f:%l:%m
This will make the location list understand the output format better

The second value is not needed, it's there in the default 'grepformat' string, and it's better to only append to that value instead of overwriting it, in case you don't have rg installed, you'll still have a usable grepformat value, so something like:

if executable('rg') | set grepformat+=%f:%l:%c:%m grepprg=rg <options you prefer> | endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants