scalpel.nvim is a Neovim plugin designed to expedite your find/replace workflow within a buffer. It sets up Neovim's native substitution
command, automating some steps to reduce some typing.
Install scalpel.nvim with your preferred plugin manager.
The following example shows the installation process using lazy.nvim. It sets the scalpel substitute keymap to <leader>e
.
{
'wassimk/scalpel.nvim',
version = "*",
config = true,
keys = {
{
'<leader>e',
function()
require('scalpel').substitute()
end,
mode = { 'n', 'x' },
desc = 'substitute word(s)',
},
},
}
Note
You can set the keymap to anything you wish.
- Move the cursor over the word to replace
- Trigger the substitution with your keymap
- Begin typing the desired substitution and hit return
- Use visual mode (
v
) to select the word(s) to replace within a single line - Trigger the substitution with your keymap
- Begin typing the desired substitution and hit return
- Highlight word(s) to substitute with
*
or/
- Use visual line mode (
V
) to highlight the lines with the word(s) to substitute - Trigger the substitution with your keymap
- Begin typing the desired substitution and hit return
Tip
The word(s) being replaced during substitution are available in the replacement text using &
.
This project was inspired by Scalpel, a Vimscript plugin I've used for many years. scalpel.nvim is my version, which was reimagined and implemented in Lua for fun.