Skip to content

Commit

Permalink
basics: vim style seach and replace
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalli-johnny committed Jul 11, 2023
1 parent 13d9440 commit 87de8f0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/neovim-basics/search-replace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Search and Replace

`:substitute` or `:s` vim command will highlight the matches for a text pattern and substitute for a new pattern

Built-in help for the command

```vim
:help :substitute
```

??? HINT "Multiple cursors can also be used for multiple substitutions"
[multiple cursors](multiple-cursors.md) created on each occurance can be used to search and replace a pattern


Subsitute the first matching patterns in the current line

```vim
:s/current-pattern/new-pattern
```

Subsitute all the matching patterns in the current line, `g` representing all occurances in a line

```vim
:s/current-pattern/new-pattern/g
```

Use `%` to specify the current buffer as the scope to change all matches

```vim
:%s/current-pattern/new-pattern/g
```

0 comments on commit 87de8f0

Please sign in to comment.