VIM如何搜索单字节表示

时间:2022-12-05 03:58:05

When I cut and paste from a Word document into VIM, quotes get translated into a-circumflex followed by <99>, where the <99> is a single byte representation. (Which I know because when I move to it, typing a single 'l' moves me right to the over all four characters).

当我从Word文档剪切并粘贴到VIM中时,引号会被转换为a-circumflex,后跟<99>,其中<99>是单字节表示。 (我知道,因为当我移动它时,键入一个'l'会让我直接移动到所有四个角色)。

I want to do search and replace, and I know enough to find the a-cirumflex digraph using control-K a>, but I can't figure out how to search for the <99>, and searching for the literal /<99> doesn't work.

我想做搜索和替换,我知道足够使用control-K a>找到a-cirumflex有向图,但我无法弄清楚如何搜索<99>,并搜索文字/ <99 >不起作用。

So I really have two questions:

所以我真的有两个问题:

What help topic should I consult in vim to learn about what sort of a beast the <99> is (since it doesn't seem to be a digraph) (or maybe it IS a digraph and I'm missing something)?

我应该在vim中咨询哪些帮助主题,以了解<99>是什么类型的野兽(因为它似乎不是一个有向图)(或者它可能是有向图并且我遗漏了一些东西)?

How do I search for a single character represented by <99>?

如何搜索由<99>表示的单个字符?

3 个解决方案

#1


Try this:

Put your cursor over the character, type ga and you will see the hexadecimal representation of the character, then you can replace it with:

将光标放在字符上,键入ga,您将看到该字符的十六进制表示,然后您可以将其替换为:

:%s/\%xNN//g

Where NN is the hex code of the character.

其中NN是字符的十六进制代码。

#2


Is'n it relates vim shows question mark instead of character ?

它是否与vim有关,而不是字符?

It could be unicode character 0x0099, which has no graphical representation.

它可能是unicode字符0x0099,没有图形表示。

How to insert unicode - "u0099 in INSERT mode inserts a character with the unicode value 0x0099." (from here)

如何插入unicode - “在INSERT模式下u0099插入一个unicode值为0x0099的字符。” (从这里)

#3


@CMS detailed searching directly for the character value. If the character is a word by itself (or you can add spaces quickly to make it so), you can also cursor over the character and type ***** -- which will search forward for the closest word to the cursor (# to go backwards).

@CMS详细搜索直接查找字符值。如果角色本身就是一个单词(或者你可以快速添加空格来实现它),你也可以将光标放在角色上并输入***** - 它将向前搜索最接近光标的单词(#倒退)。

#1


Try this:

Put your cursor over the character, type ga and you will see the hexadecimal representation of the character, then you can replace it with:

将光标放在字符上,键入ga,您将看到该字符的十六进制表示,然后您可以将其替换为:

:%s/\%xNN//g

Where NN is the hex code of the character.

其中NN是字符的十六进制代码。

#2


Is'n it relates vim shows question mark instead of character ?

它是否与vim有关,而不是字符?

It could be unicode character 0x0099, which has no graphical representation.

它可能是unicode字符0x0099,没有图形表示。

How to insert unicode - "u0099 in INSERT mode inserts a character with the unicode value 0x0099." (from here)

如何插入unicode - “在INSERT模式下u0099插入一个unicode值为0x0099的字符。” (从这里)

#3


@CMS detailed searching directly for the character value. If the character is a word by itself (or you can add spaces quickly to make it so), you can also cursor over the character and type ***** -- which will search forward for the closest word to the cursor (# to go backwards).

@CMS详细搜索直接查找字符值。如果角色本身就是一个单词(或者你可以快速添加空格来实现它),你也可以将光标放在角色上并输入***** - 它将向前搜索最接近光标的单词(#倒退)。