6

How can I search for a ~ (tilde) in vim?

I tried /\~ and / \~ as /~ does not work.

Thanks for your help!

florianbaer
  • 170
  • 1
  • 11
  • See [this answer](https://stackoverflow.com/a/8447640/733637) in [vim: how to search/replace special chars?](https://stackoverflow.com/questions/8447561/vim-how-to-search-replace-special-chars), possibly it applies to your problem, too. – CiaPan Sep 07 '17 at 08:35
  • 2
    `/\~` works here and `/[~]` should work too – Kent Sep 07 '17 at 08:37
  • @Kent Thanks! Works on my machine with the `/[~]` – florianbaer Sep 07 '17 at 08:39

1 Answers1

11

/\~ works here. (with magic as default)

There are other ways,

  • you can search by character class: /[~]
  • you can search in nomagic mode /\M~
  • you can search in very nomagic mode /\V~
Kent
  • 189,393
  • 32
  • 233
  • 301