A Neovim plugin for fast, interactive, project-wide search and replace using fd and sad. Provides a floating terminal UI, glob filtering, and visual-mode integration for easy code refactoring.
*.lua
, src/*.js
) to filter files.git
directories from replacements$PATH
$PATH
Install using your preferred Neovim package manager.
use "mahyarmirrashed/search-and-replace.nvim"
Plug "mahyarmirrashed/search-and-replace.nvim"
{
"mahyarmirrashed/search-and-replace.nvim",
config = function()
require("search-and-replace").setup()
end,
}
The plugin provides two main commands:
:SearchAndReplace <search> <replace> [glob]
Search and replace across your project. Optionally filter files with a glob pattern.:'<,'>SearchAndReplaceVisual <replace> [glob]
Use your visual selection as the search term, and replace across matching files.foo
with bar
in all files::SearchAndReplace foo bar
foo
with bar
only in .lua
files::SearchAndReplace foo bar *.lua
replacement
in all files::'<,'>SearchAndReplaceVisual replacement
replacement
only in .js
files::'<,'>SearchAndReplaceVisual replacement *.js
setup()
Registers the user commands. Call this in your Neovim config:
require("search-and-replace").setup()
:SearchAndReplace <search> <replace> [glob]
*.lua
, src/*.js
). Defaults to all files.:'<,'>SearchAndReplaceVisual <replace> [glob]
v
, V
, or Ctrl-v
).:SearchAndReplaceVisual replacement [glob]
.The selected text becomes the search pattern.