开发者

How do I search for a special character using the character's code point in vim?

开发者 https://www.devze.com 2023-03-26 11:24 出处:网络
I want to be able to find or replace a character in vi by using 开发者_运维知识库the decimal or hex number for a character. Like character 92 for example.

I want to be able to find or replace a character in vi by using 开发者_运维知识库the decimal or hex number for a character. Like character 92 for example.

Is this possible?


To just search for the ASCII character with a hex value of 0x5c (which is 92 in decimal), use the search pattern:

/\%x5c

If you want to search for all occurrences of that character in a file and replace them with another character (or characters), you can enter this command:

:%s/\%x5c/replacement text/gc

You can, of course, replace 5c with the ASCII hex value of whatever character you wish to replace.

I found this information here via a google search for "vim replace ascii character"

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号