How to search/replace special chars?
Solution 1
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.
Solution 2
If you want to quickly select this extraneous character everywhere and replace it / get rid of it, you could:
- isolate one of the strange characters by adding a space before and after it, so it becomes a "word"
- 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. - replace last searched item by something else, globally:
:%s//something else/
Solution 3
-
replace
^@
:%s/\%x00//g
-
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
Olivier Pons
Remote Software Engineer. Website development + Native Mobile (Unity / C#) Languages / skills (order of daily use): Python / Django JavaScript JavaScript / jQuery HTML C# Php Old loves: C - Pascal - C++ Strong skills: vim and ssh for remote development Professional websites: Django / Python https://www.cogofly.com/ Blog (800 visits/day) https://olivierpons.fr/ Wordpress (100% custom multilanguage admin plugin) http://www.krystallopolis.com Php (high performance framework v3) v3 - full rewrite v3 - (so it belongs to my company) http://www.papdevis.fr v2 http://pretassur.fr http://groupe-synergies.fr v1 http://www.acarat.fr/ Personal websites: http://labyz.fr/ http://wipwip.com/ http://wogwog.com/ http://doonoo.com/
Updated on December 02, 2020Comments
-
Olivier Pons over 3 years
After a copy-paste from Wikipedia into Vim, I get this:
1 A 2 3 [+] Métier agricole<200e> – 44 P • 2 C 4 [×] Métier de l'ameublement<200e> – 10 P 5 [×] Métier de l'animation<200e> – 5 P 6 [+] Métier en rapport avec l'art<200e> – 11 P • 4 C 7 [×] Métier en rapport avec l'automobile<200e> – 10 P 8 [×] Métier de l'aéronautique<200e> – 15 P
The problem is that
<200e>
is only a char.I'd like to know how to put it in a search/replace (via the
/
or:
).