Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docs:vim:search_and_replace [2009/01/22 11:21] – billh | docs:vim:search_and_replace [2009/01/22 11:27] (current) – billh | ||
---|---|---|---|
Line 6: | Line 6: | ||
* g - tells vim to replace all instances on each line, instead of just the first | * g - tells vim to replace all instances on each line, instead of just the first | ||
- | ===== Metacharacters | + | ==== Metacharacters ==== |
|. |any character except new line | | |. |any character except new line | | ||
|\s |whitespace character | | |\s |whitespace character | | ||
Line 44: | Line 44: | ||
Search results can be replaced with special characters like this: | Search results can be replaced with special characters like this: | ||
* type :%s/SEARCH/ | * type :%s/SEARCH/ | ||
- | * press CTRL-V (CTRL-Q on windows) | + | * press CTRL-V (CTRL-Q on windows); you now have the option to: |
- | * now type the 3 digit decimal value for the character you want | + | * type the 3 digit decimal value for the character |
+ | * type x then the 2 character hex value you want | ||
+ | * type o then the 3 digit octal value you want | ||
* full example to replace all occurances of SEARCH with a vertical tab:< | * full example to replace all occurances of SEARCH with a vertical tab:< | ||
:%s/SEARCH/ | :%s/SEARCH/ | ||
(press CTRL-V or CTRL-Q) | (press CTRL-V or CTRL-Q) | ||
- | 011/g | + | (press the letter o) |
+ | 013/g | ||
</ | </ | ||
+ | * once the replace is done, you can move the cursor over the character and type ' |