Ⅰ. 插件描述
Stop Unicode trolls from messing with your code.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'vim-utils/vim-troll-stopper'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'vim-utils/vim-troll-stopper'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'vim-utils/vim-troll-stopper'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-utils/vim-troll-stopper
Ⅳ. 文档说明
# vim-troll-stopper
Beware, there are (Unicode) trolls out there! Here, take this plugin for
protection.
Problem
There are many Unicode characters that are identical or look very
similar to one another. Best known example: semicolon (;) and a greek question
mark (;).
Trollers (e.g. your coworkers) can exploit this by replacing semicolons with
greek question marks in your code (original idea: Peter Ritchie, @peterritchie).
There are even tools that help you with
this and take it to the next level.
Also, any random code snippet from the internet/stackoverlow can be corrupt.
Demo, a cannonical "hello troll" program:
ⅰnt ⅿain() { рrintf ("Ηello troll!\n"); }
Copy-paste the above code to hello.c file and run $ make hello. Part of the
output:
hello.c:1:1: error: unknown type name 'ⅰnt'
ⅰnt ⅿain() { рrintf ("Ηello troll!\n"); }
^
Maybe you'd even start crying if you didn't know the above code is deceitful.
Solution
Vim users should know better than falling for these petty tricks.
This plugin highlights troll characters with a red background so you are alerted
something is not right.

After you install this plugin, things should just work for any and all
filetypes.
Installation
Just use your favorite vim plugin manager.
Features
- change highlight to custom color (in
.vimrc)highlight TrollStopper ctermbg = red guibg = #FF0000
- use the
:TrollStopcommand to convert invalid characters to regular ones