macos Mac Vim:如何将默认文本颜色更改为绿色?默认字体?Macvim 手册?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3097416/
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-10-21 07:01:22  来源:igfitidea点击:

Mac Vim: How can I change the default text color to be green? Default font? Macvim manual?

macosvimmacvim

提问by sixtyfootersdude

I have installed MacVim but I cannot figure out how to do some formatting things.

我已经安装了 MacVim,但我不知道如何做一些格式化的事情。

The screen shot below shows:

下面的屏幕截图显示:

  • the file class1.jak (custom file type I have defined) open in both macvim and vim
  • the left one is macvim
  • the right one is the terminal
  • 在 macvim 和 vim 中打开的文件 class1.jak(我定义的自定义文件类型)
  • 左边的是macvim
  • 正确的是终端

Here is what I would like to do:

这是我想做的事情:

  1. The default color of my terminal is green. I would like the default text color to be green for mac vim as well.

  2. The font is strange in macvim. How can I change that.

  3. I think that both of these are very basic macvim questions but I could not find a really good mac vim reference. I read the :help macvimbut I didn't find it that helpful. What should I read to understand macvim formatting and features better? Is there a tutorial somewhere? I feel pretty happy with my vim skills in general but this is the first gvim I have used.

  1. 我的终端的默认颜色是绿色。我也希望 mac vim 的默认文本颜色为绿色。

  2. macvim 中的字体很奇怪。我怎样才能改变它。

  3. 我认为这两个都是非常基本的 macvim 问题,但我找不到一个非常好的 mac vim 参考。我阅读了,:help macvim但我发现它没有帮助。我应该阅读什么才能更好地理解 macvim 格式和功能?某处有教程吗?总的来说,我对自己的 vim 技能感到非常满意,但这是我使用的第一个 gvim。

http://torch.cs.dal.ca/~summers/Picture%205.png

http://torch.cs.dal.ca/~summers/Picture%205.png

This is my .gvimrc:

这是我的.gvimrc

set background=dark
set go-=T

This is the color scheme for .jak files located in (~/.vim/syntax/jak.vim):

这是位于 ( ~/.vim/syntax/jak.vim) 中的.jak 文件的配色方案:

 16         "===============
 17         " Titles
 18         "===============
 19 
 20                 syn region JakeSubSubtitle start=+= + end=+ =\n+ oneline
 21                 highlight JakeSubSubtitle ctermfg=cyan guifg=cyan
 22 
 23                 syn region JakeSubtitle start=+== + end=+==+ oneline
 24                 highlight JakeSubtitle ctermbg=black ctermfg=DarkMagenta guifg=DarkMagenta
 25 
 26                 syn region JakeTitle start=+=== + end=+===+ oneline
 27                 highlight JakeTitle ctermbg=black ctermfg=Yellow guifg=yellow
 28 
 29                 syn region JakeMasterTitle start=+==== + end=+====+ oneline
 30                 highlight JakeMasterTitle cterm=bold term=bold ctermbg=black ctermfg=LightBlue guifg=LightBlue
 31 
 32         "===============
 33         " Keywords
 34         "===============
 35 
 36                 syn keyword JakeKeywords        AssQuestion Question TODO Answer JAKEHTTPS PossibleProblem Note done LowPrio
 37                 highlight JakeKeywords cterm=bold term=bold ctermbg=black ctermfg=blue guifg=blue
 38 
 39                 syn keyword JakeRedKeywords     Priority HighPriority containedin=ALL
 40                 highlight JakeRedKeywords cterm=bold term=bold ctermbg=black ctermfg=Red
 41 
 42                 syn keyword JakeLongTermKeywords ReturnTo Ask containedin=all
 43                 highlight JakeLongTermKeywords ctermfg=lightGreen

回答by redacted

For the font issue (in .gvimrc):

对于字体问题(在 .gvimrc 中):

set guifont=Menlo:h11.00

will set the font in MacVim to Menlo, size 11.

将 MacVim 中的字体设置为 Menlo,大小为 11。

As for the syntax highlighting, it might just be that the colorscheme you are using in console vim is not being picked up by MacVim:

至于语法高亮,可能只是您在控制台 vim 中使用的颜色方案没有被 MacVim 接收:

colorscheme xoria256

Putting this command in .gvimrc will use the xoria256 colorscheme (for example). I have found that the colorscheme setting in .vimrc are not always picked up correctly.

将此命令放在 .gvimrc 中将使用 xoria256 颜色方案(例如)。我发现 .vimrc 中的颜色方案设置并不总是正确选择。

回答by dar512

If you'd like to experiment with your font settings try

如果您想尝试使用字体设置,请尝试

:set guifont=*

That will allow you to choose a font using the standard mac font window. Once you've found the font you like, type:

这将允许您使用标准的 mac 字体窗口选择字体。找到喜欢的字体后,输入:

:set guifont=<tab>

It will show you what the current setting is for guifont. Then you can type that into your .gvimrc.

它会告诉你 guifont 的当前设置是什么。然后您可以将其输入到您的 .gvimrc 中。

回答by Ether

I'm not on a mac right now so I can't find the exact reference for you, but I found that while playing around in the menus, one can manually change some of these settings... and then to bring up the configuration file to see what those settings translate to in words. As a result, I was able to add these lines to my standard ~/.vimrc (which Macvim does read), in order to change the font:

我现在不在 Mac 上,所以我找不到你的确切参考,但我发现在菜单中播放时,可以手动更改其中一些设置......然后调出配置文件以查看这些设置转换为文字的内容。结果,我能够将这些行添加到我的标准 ~/.vimrc(Macvim 确实读取)中,以更改字体:

set gfn=Monaco:h10

You should be able to find similar settings for colours very nearby. (I'll edit this answer when I get back to my mac to add more details... you'll have to wait ~6 hours though.)

您应该能够为非常接近的颜色找到类似的设置。(当我回到我的 mac 以添加更多详细信息时,我将编辑此答案……不过,您必须等待大约 6 个小时。)

回答by Tim C

You can change the font with this command:

您可以使用以下命令更改字体:

set gfn=<your font settings>

Vim GFN documentation

Vim GFN 文档

The text color is a bit more complicated because it is syntax highlighting. But you can change this the same way you change the text color in any whatever version of vim you have used before. I use GVIM for Mac every day and I don't notice any differences between it and GVIM for Windows, for example. For color schema changes might I suggest this great script:

文本颜色有点复杂,因为它是语法高亮显示。但是您可以像更改以前使用过的任何版本的 vim 中的文本颜色一样更改它。例如,我每天都使用 Mac 版 GVIM,我没有注意到它与 Windows 版 GVIM 之间有任何区别。对于颜色模式更改,我可能会建议这个很棒的脚本:

Color Scheme Sampler Pack

配色方案采样包

It should give you a lot of great color schemes to try, and any of them can be easily edited, so it's a good starting point. Good luck!

它应该会为您提供很多很棒的配色方案供您尝试,而且其中任何一个都可以轻松编辑,因此这是一个很好的起点。祝你好运!

回答by Dummy00001

Long story short: :h :hi(:h is a shortcut for :help, :hi for :highlight) and look for the guifg.

长话短说:(:h :hi:h 是 :help 的快捷方式,:hi 是 :highlight 的快捷方式)并查找guifg.

In your custom color scheme you define only ctermpart - the guifg, guibg, etc are all missing. That's why VIM in GUI mode is using default colors from your color scheme (:h :colo).

在您的自定义配色方案中,您只定义了cterm一部分 - guifgguibg等都丢失了。这就是 GUI 模式下的 VIM 使用您的配色方案中的默认颜色 ( :h :colo) 的原因。