Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace ~ (tilde) in vim

Tags:

replace

vim

I have a string with a ~ in it and using the expression

Example:

hi~how~are~you

:%s/~/ /g

This doesn't seem to work any ideas?

like image 396
Jeremy E Avatar asked Mar 28 '11 14:03

Jeremy E


2 Answers

The symbol ~ matches the previous substitute string (see :help /~), so you need to prefix it with a backslash:

:%s/\~/ /g
like image 121
DrAl Avatar answered Oct 03 '22 02:10

DrAl


You just need to escape it with a backslash:

:%s/\~/ /g
like image 7
Paul Ruane Avatar answered Oct 03 '22 02:10

Paul Ruane