Saturday 31 August 2019

gvim - How to remove this symbol "^@" with vim?


I have some files that are corrupted with this symbol:



^@



It's not part of the string; it's not searchable. How do I substitute this symbol with nothing, or how do I delete this symbol?


Here is an example line from one file:


^@F^@i^@l^@e^@n^@a^@m^@e^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@ ^@:^@ ^@^M^@

Answer



You could try:




  • %s///g (on regular PCs)




  • %s///g (on Mac PCs)




where means first press down the CTRL on regular PCs, keeping it as pressed down, hit 2, release CTRL.


and means first press down the control on Mac PCs, keeping it as pressed down, press down shift on Mac PCs, keeping it as pressed down, hit 2, release control and shift.


Finally, both of the two commands should result in %s/^@//g on screen. ^@ means a single character (a NULL byte, which otherwise couldn’t be displayed), not ^ followed by @, so you can't just type ^ and @ in a row in the above command.


This command removes all the ^@.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...