-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13d9440
commit 87de8f0
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|