Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s1n7ax/nvim-search-and-replace
Really simple plugin to search and replace multiple files
https://github.com/s1n7ax/nvim-search-and-replace
neovim neovim-plugin search-and-replace
Last synced: 14 days ago
JSON representation
Really simple plugin to search and replace multiple files
- Host: GitHub
- URL: https://github.com/s1n7ax/nvim-search-and-replace
- Owner: s1n7ax
- License: mit
- Created: 2021-09-01T07:07:29.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-06T10:22:37.000Z (about 2 years ago)
- Last Synced: 2024-07-31T20:44:37.880Z (3 months ago)
- Topics: neovim, neovim-plugin, search-and-replace
- Language: Lua
- Homepage:
- Size: 12.7 KB
- Stars: 71
- Watchers: 6
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - s1n7ax/nvim-search-and-replace - Search and replace in multiple files at the same time from the current working directory. (Search / PHP)
README
# nvim-search-and-replace
Absolutly minimal plugin to search and replace multiple files in current working directory. This only uses `vim` built-in features to search and replace
## Install
```lua
use {
's1n7ax/nvim-search-and-replace',
config = function() require'nvim-search-and-replace'.setup() end,
}
```## Keymaps
leader + g + r = Search and replace (Respects
ignored files)leader + g + R = Search and replace
everything (Don't give a shit about the ignored files)leader + g + u = Search, replace and save (Respects
ignored files)leader + g + U = Search, replace and save
everything (Don't give a shit about the ignored files)## Commands
```vim
:SReplace - Search and replace
:SReplaceAll - Search and replace all including ignored files
:SReplaceAndSave - Search, replace and save
:SReplaceAllAndSave - Search, replace and save including ignored files
```## Syntax
### Search Query Syntax
`:h su` for more information
```
//
//
/
//```
Ex:-
```lua
-- search the word "test" in ".js" files and replace them glabally in every file
/test/g **/*.js-- search the word "test" in all files and replace them glabally in every file
test/g-- search the word "test" in all files and replace one time for single line
test-- seach any word starts with "te" and ends with "st" and replace one time for single line
te.*st-- seach "print(something)" and add something to match group
print(\(.*\))
```### Replace Query Syntax
```
```
Ex:-
```
-- replace the matched queries with "test"
test-- replace the matched queries with "console.log" and replace \1 with the first
match value
console.log(\1)
```## Configurations
```lua
require('nvim-search-and-replace').setup{
-- file patters to ignore
ignore = {'**/node_modules/**', '**/.git/**', '**/.gitignore', '**/.gitmodules','build/**'},-- save the changes after replace
update_changes = false,-- keymap for search and replace
replace_keymap = 'gr',-- keymap for search and replace ( this does not care about ignored files )
replace_all_keymap = 'gR',-- keymap for search and replace
replace_and_save_keymap = 'gu',-- keymap for search and replace ( this does not care about ignored files )
replace_all_and_save_keymap = 'gU',
}
```## Available functions
```lua
require('nvim-global-replace').setup(config)-- require('nvim-global-replace').search_and_replace({
-- ignore = { 'tests/**'} , update_changes = true
-- })
require('nvim-global-replace').replace(opts)-- require('nvim-global-replace').search_and_replace({
-- update_changes = true
-- })
require('nvim-global-replace').replace_all(opts)
```