fix vim search
This commit is contained in:
27
writing/vim/subs.md
Normal file
27
writing/vim/subs.md
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
title: "find and replace"
|
||||
tags: [ "vim", "search", "replace", "find" ]
|
||||
requires: [ "vim basics" ]
|
||||
---
|
||||
Search for the next and or previous occurrence of the word under your cursor with `*` and `#`.
|
||||
|
||||
Search and replace the first 'one' found with 'two':
|
||||
|
||||
`:%s/one/two/`
|
||||
|
||||
Run the last substitution globally:
|
||||
|
||||
`g&`
|
||||
|
||||
Same, but just replace 'one' globally:
|
||||
|
||||
`:%s/one/two/g`
|
||||
|
||||
Put quotes around every occurrence of `$HOME`:
|
||||
|
||||
`:%s/$HOME/"&"`
|
||||
|
||||
Same, but add curly brackets around `$HOSTNAME`:
|
||||
|
||||
`:%s/$HOSTNAME/{&}`
|
||||
|
||||
Reference in New Issue
Block a user