Menu

1 / 4

Neovim Grepping and File Search Without Plugins

DEV Community·khalil chermiti·6 months ago
#Gtj6W7hw
#better#neovim#software#coding#enter
Reading 0:00
15s threshold

Neovim already has powerful built-in tools for searching text and files.

You don't need Telescope or any plugin for basic workflow.

Grepping Text with :grep

Neovim can use any external search tool through :grep .

Check the current grep program:

: set grepprg ?

Enter fullscreen mode

Exit fullscreen mode

Most setups will show something like:

grepprg = rg -- vimgrep - uu

Enter fullscreen mode

Exit fullscreen mode

This means Neovim uses ripgrep ( rg ) for searching.

Better grepprg Configuration

A good default setup:

vim . opt . grepprg = "rg --vimgrep --smart-case --hidden"

Enter fullscreen mode

Exit fullscreen mode

What these flags do

Flag Description

--vimgrep Output format compatible with quickfix

--smart-case Ignore case unless uppercase is used

--hidden Search hidden files too

You can also exclude useless folders:

vim . opt . grepprg = "rg --vimgrep --smart-case --hidden " .. "--glob '!node_modules' " .. "--glob '!.git' " .. "--glob '!dist' " ..…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.