bash vim 终端 OS X Mountain Lion 中的光标颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11878484/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 02:57:45  来源:igfitidea点击:

Cursor color in vim terminal OS X Mountain Lion

bashvimterminalmacvim

提问by Jose187

I want to make the cursor and selected text easier to read in vim (white background, black foreground), so i've done

我想让光标和选定的文本在 vim 中更容易阅读(白色背景,黑色前景),所以我已经完成了

hi Visual guibg=white guifg=black gui=NONE ctermfg=black ctermbg=white cterm=reverse
hi Cursor guibg=white guifg=black gui=NONE ctermfg=black ctermbg=white cterm=reverse

which gives me exactly what i want on MacVim. On the vim terminal, however, it defaults to the terminal preferences, which is very difficult to read and find...how can i override the terminal defaults?

这正是我在 MacVim 上想要的。然而,在 vim 终端上,它默认为终端首选项,这很难阅读和找到……我如何覆盖终端默认值?

Edit:to say that the hi Visuallike works perfectly. It's the hi Cursorthat doesn't.

编辑:hi Visual喜欢完美地工作。是hi Cursor那个没有。

回答by Prince Goulash

I am not a Mac user, but I don't believe this is possible. The cursor colour in console Vim is inherited from the terminal application, and can't be modified.* You could try changing the cursor colour in the terminal preferences.

我不是 Mac 用户,但我不相信这是可能的。控制台 Vim 中的光标颜色继承自终端应用程序,无法修改。* 您可以尝试在终端首选项中更改光标颜色。

*Disclaimer: this is certainly true of the Windows command prompt, which I am forced to use at work. It wouldn't surprise me if other Unix-like shells were more flexible.

*免责声明:这当然适用于我在工作中被迫使用的 Windows 命令提示符。如果其他类 Unix 的 shell 更灵活,我不会感到惊讶。

回答by gib

You can't change the cursor colour programatically (i.e. just do it for vim), but you can change it in Terminal>Preferences>Profiles>Text>Cursor (see image), which may solve your issue.

您无法以编程方式更改光标颜色(即仅针对 vim 进行更改),但您可以在终端>首选项>配置文件>文本>光标(参见图像)中更改它,这可能会解决您的问题。

I find a bright green cursor makes a big difference for visibility!

我发现亮绿色光标对可见性有很大影响!

EDIT:This is mentioned in the comments, but I missed that the first time so I think it deserves its own answer.

编辑:这是在评论中提到的,但我第一次错过了,所以我认为它应该得到自己的答案。

Terminal settings

终端设置