如何搜索不可见的控制字符 [英] How to search for invisible control characters

查看:131
本文介绍了如何搜索不可见的控制字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在stackoverflow上有一些关于此的线程,但是当我在编辑器中编写:set list"时,它似乎显示隐藏的字符,但是在我们遇到问题的代码中却不显示隐藏的字符.

I know there are some threads about this on stackoverflow but when i write ":set list" in the editor, it seems to display hidden characters but it doesnt display the hidden characters in the code we are having problems with.

有时候,我们的代码中有一些不可见的符号,如果循环中断,我不知道这些符号如何到达那里,除了一些错误的键盘组合被意外键入了.代码本身看起来是正确的,但是不可见符号会破坏它.

Some times now we have had some invisible symbols in our code making if loops break, i dont know how the symbols get there except from that some wierd keyboard combination much have been accidentally typed in. The code itself looks correct but the invisible symbol breaks it.

我已经在网上搜索了这个,但是我所能找到的似乎只是vim中的:set list"命令,除了必须更改隐藏字符的颜色外,但是尽管这似乎显示了一些隐藏字符,但它并没有显示显示有问题的.我们得到了两个符号,看起来像一个十字架,一个看起来像手枪.我们还尝试过在崇高的文本中添加"draw_white_space"设置,但这似乎只显示出来,好吧,象它说的那样,但是结果在Google上显示为显示隐藏字符,所以我尝试了一下.

I have searched online about this but all i can find seems to be the ":set list" command in vim in addition to have to change the color of the hidden characters, but while this seems to display some hidden characters it doesnt display the problematic ones. We are getting two symbols which looks like a cross and one looks like a pistol. We have also tried to add the "draw_white_space" setting in sublime text but this only seems to display, well, whitspace like it says but the result was shown on google for showing hiden characters so i gave it a try.

我们能够使用DiffMerge工具查看符号的唯一方法是,我们无法在任何其他编辑器中查看这些符号,但实际上我们已经能够将符号复制到其自己的文件中, grep使用-f grep选项可以遍历所有文件,但是使用键盘绑定在vim中显示字符会更容易.

The only way we have been able to see where the symbols are is with the DiffMerge tool, we have not been able to see these symbols in any other editor but we have actually been able to copy the sign to its own file and grep through all the files with the -f grep option which works, but it would be easier to display the characters in vim but using a keybinding.

有人有什么建议吗?当问题是看不见的符号时,这使我们花费更多的时间调试代码.

Does someone have any suggestions? This is causing us to use a lot more time debugging the code when the problems is an invisible symbol.

推荐答案

尝试以下搜索命令:

/[^ -~<09>]

(通过按Tab键可获得<09>).或者,如果您想摆脱那些讨厌的标签,只需:

(you get the <09> by pressing the tab key). Or if you want to get rid of those nasty tabs, just:

/[^ -~]

这将找到并突出显示任何非ASCII或控制ASCII字符.

That will find and highlight any non-ASCII or control-ASCII character.

如果仍然有隐藏的字符,可以在搜索之前尝试以下命令:

If you still have hidden characters out there, you can try this command before the search:

:set enc=latin1

这将防止任何奇怪的Unicode字符出现在您的代码中.

That will prevent any weird Unicode character to show up in your code.

这篇关于如何搜索不可见的控制字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆