在 Mac OS X 终端的 vim 中显示软连字符
vim 与 Mac OS X 终端中的软连字符 (0xAD
) 完全混淆。不显示,虽然“虚拟列”号是对的,但是插入乱了。
因此,如果我有一行带有 ab
的行,其中 -
是软连字符,它在 vim 中显示为 ab
,当我尝试替换时将字符 b
替换为 c
,我得到的是 acb
。相当混乱。
pico
也会发生同样的情况,但 emacs
则不然。
有办法解决这个问题吗?
我在 Mac OS X 的终端中使用 vim。
vim is totally confused with soft hyphen characters (0xAD
) in the Mac OS X Terminal. It is not displayed, although the "virtual column" number is right, the insertion is messed up.
So if I have a line with a-b
, where -
is the soft hyphen, it shows as ab
in vim, and when I try to replace the character b
by c
, I obtain instead acb
. Quite confusing.
The same happens with pico
, but not with emacs
.
Is there a way to fix this?
I'm using vim in the Terminal of Mac OS X.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
iTerm2 不存在软连字符的问题。
@Kevin Ballard 如果您在 MacVim 的首选项中打开“实验渲染器”,MacVim 会正确渲染软连字符。
iTerm2 does not have this issue with soft hyphens.
@Kevin Ballard If you turn on the "Experimental Renderer" in MacVim's preferences, MacVim renders the soft hyphens correctly.
Unicode 分配 U+00AD SOFT HYPHEN 字符东亚宽度不明确,这意味着它占用一或两个终端列 - 它应该以可见方式呈现 - 但终端使用 OS X 中可用的完整 Unicode 文本呈现器,它不会呈现软连字符除非它正在执行断行。
有趣的是,
emacs
通过向终端发送连字符来显示软连字符,而不是依赖它来呈现软连字符。vim
只是将软连字符发送到终端并假设它将被显示。从 OS X Mountain Lion 10.8 开始,终端显示软连字符。
Unicode assigns the U+00AD SOFT HYPHEN character East Asian Width Ambiguous, which means it occupies one or two terminal columns—it should be rendered visibly—but Terminal uses the full Unicode text renderer available in OS X, which doesn't render soft hyphens unless it's performing line breaking.
Interestingly,
emacs
displays soft hyphens by sending a hyphen to the terminal instead of depending on it to render the soft hyphen.vim
just sends the soft hyphen to the terminal and assumes it will be displayed.As of OS X Mountain Lion 10.8, Terminal displays soft hyphens.