2022-01-16 18:20:39 +00:00
|
|
|
---
|
2022-02-03 19:10:35 +00:00
|
|
|
title: "vim search"
|
2022-01-16 18:20:39 +00:00
|
|
|
tags: [ "Documentation", "vim" ]
|
|
|
|
---
|
2023-04-16 12:49:47 +00:00
|
|
|
Search for the next and or previous occurrence of the word under your cursor with `*` and `#`.
|
|
|
|
|
2020-01-15 01:05:53 +00:00
|
|
|
Search and replace the first 'one' found with 'two':
|
|
|
|
|
|
|
|
> :%s/one/two/
|
|
|
|
|
|
|
|
Same, but replace 'one' globally:
|
|
|
|
|
|
|
|
> :%s/one/two/g
|
|
|
|
|
2023-04-16 12:49:47 +00:00
|
|
|
Put quotes around every occurrence of `$HOME`:
|
|
|
|
|
|
|
|
> :%s/$HOME/"&"
|
|
|
|
|
|
|
|
Same, but add curly brackets around `$HOSTNAME`:
|
|
|
|
|
|
|
|
> :%s/$HOSTNAME/{&}
|
|
|
|
|