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.
- Interactive search and replace using sad in a floating terminal
- Uses fd for fast, flexible file finding
- Supports glob patterns (e.g.
*.lua,src/*.js) to filter files - Always excludes
.gitdirectories from replacements - Visual mode integration: use your selection as the search term
- Simple, dependency-light, and Neovim-native
- Neovim 0.7.0 or later (for floating window and Lua API support)
- fd installed and in your
$PATH - sad installed and in your
$PATH
Install using your preferred Neovim package manager.
Using packer.nvim
use "mahyarmirrashed/search-and-replace.nvim"Using vim-plug
Plug "mahyarmirrashed/search-and-replace.nvim"Using lazy.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.
- Replace
foowithbarin all files:
:SearchAndReplace foo bar
- Replace
foowithbaronly in.luafiles:
:SearchAndReplace foo bar *.lua
- Visually select text, then replace it with
replacementin all files:
:'<,'>SearchAndReplaceVisual replacement
- Visually select text, then replace it with
replacementonly in.jsfiles:
:'<,'>SearchAndReplaceVisual replacement *.js
Registers the user commands. Call this in your Neovim config:
require("search-and-replace").setup()- search: The pattern to search for (regex supported).
- replace: The replacement string.
- glob (optional): Glob pattern for files (e.g.
*.lua,src/*.js). Defaults to all files.
- Uses your last visual selection as the search pattern.
- replace: The replacement string.
- glob (optional): Glob pattern for files.
- Select text in visual mode (
v,V, orCtrl-v). - Type
:SearchAndReplaceVisual replacement [glob].
The selected text becomes the search pattern.
