How to search/replace special chars?

  1. replace ^@

    :%s/\%x00//g

  2. replace ^L

    // Enter the ^L using ctrl-V ctrl-L

    :%s/^L//g

refers:

  • gvim - How to remove this symbol "^@" with vim? - Super User
  • vim - Deleting form feed ^L characters - Stack Overflow

If you want to quickly select this extraneous character everywhere and replace it / get rid of it, you could:

  1. isolate one of the strange characters by adding a space before and after it, so it becomes a "word"
  2. use the * command to search for the word under the cursor. If you have set hlsearch on, you should then see all of the occurrences of the extraneous character highlighted.
  3. replace last searched item by something else, globally: :%s//something else/

Check the help for \%u:

                                /\%d /\%x /\%o /\%u /\%U E678

\%d123  Matches the character specified with a decimal number.  Must be
        followed by a non-digit.
\%o40   Matches the character specified with an octal number up to 0377.
        Numbers below 040 must be followed by a non-octal digit or a non-digit.
\%x2a   Matches the character specified with up to two hexadecimal characters.
\%u20AC Matches the character specified with up to four hexadecimal
        characters.
\%U1234abcd     Matches the character specified with up to eight hexadecimal
        characters.

These are sequences you can use. Looks like you have two bytes, so \%u200e should match it. Anyway, it's pretty strange. 20 in UTF-8 / ASCII is the space character, and 0e is ^N. Check your encoding settings.

Tags:

Vim

Replace