Search and Substitute in VIM Editor
This post will show you, how you can easily search and substitute in VIM Editor. Below are some mostly used operations:
Search
Substitute
Search
- /{string}: search for string
- *: search for other instances of the word under your cursor
- n: go to the next instance when you’ve searched for a string
- N: go to the previous instance when you’ve searched for a string
- ;: go to the next instance when you’ve jumped to a character
- ,: go to the previous instance when you’ve jumped to a character
Substitute
- s: substitute from where you are to the next command (noun)
- S: substitute the entire current line
- :%s /foo/bar/g --- Change “foo” to “bar” on every line
- :%s /foo/bar/gc --- Interactive change “foo” to “bar” on every line
- :s /foo/bar/g --- Change “foo” to “bar” on just the current line
- :s /foo/bar/gc --- Interactive change “foo” to “bar” on just the current line
Comments
Post a Comment