macos 如何在 OS X 的终端中激活 Vim 配色方案?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1653538/
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
How can I activate Vim color schemes in OS X's Terminal?
提问by Ethan
I'm working with the Vim 7.2 that comes with Mac OS 10.6.1 (Leopard), using the Mac's "Terminal" app. I'd like to use a fancy color scheme. I did this...
我正在使用 Mac OS 10.6.1 (Leopard) 附带的 Vim 7.2,使用 Mac 的“终端”应用程序。我想使用花哨的配色方案。我做了这个...
:syntax on
Then this...
那么这...
:colorscheme slate
:colorscheme elflord
:colorscheme desert
etc...
Syntax highlighting is working, but I'm finding that regardless of the scheme I choose, the only colors displayed are the basic Red, Blue, Cyan, Gray, etc.
语法高亮有效,但我发现无论我选择哪种方案,显示的唯一颜色都是基本的红色、蓝色、青色、灰色等。
Is there a way to get the Terminal app to display a larger collection of colors to allow some more subtle schemes?
有没有办法让终端应用程序显示更大的颜色集合以允许一些更微妙的方案?
采纳答案by ashcatch
回答by skipper21
Create vimrc file on your home folder and then edit it. You can try adding syntax on inside ~/.vimrc file.
在您的主文件夹中创建 vimrc 文件,然后对其进行编辑。您可以尝试在 ~/.vimrc 文件中添加语法。
$cat ~/.vimrc
syntax on
It will highlight your code syntax on vim
它将在 vim 上突出显示您的代码语法
回答by jotacor
Add "syntax on" to the file /usr/share/vim/vimrc and you'll get highlighting in your files every time you edit one.
将“syntax on”添加到文件 /usr/share/vim/vimrc 中,每次编辑文件时都会突出显示。
# vi /usr/share/vim/vimrc
# vi /usr/share/vim/vimrc
Add this line at the end of the file:
在文件末尾添加这一行:
syntax on
Now you'll get highlighting when you edit whatever's file.
现在,当您编辑任何文件时,您将得到突出显示。
回答by ynz
You need to create file ~/.vimrcand add syntax onin that file
您需要创建文件 ~/.vimrc并在该文件中添加语法
vi ~/.vimrc
syntax on
vi ~/.vimrc
语法上
save the file and run your vim
保存文件并运行你的 vim
回答by Daniel Worthington
You might want to consider using a version of Vim that is a native Mac app (that runs in a window).
您可能需要考虑使用作为本机 Mac 应用程序(在窗口中运行)的 Vim 版本。
MacVimhas great color schemes and you can still launch it from Terminal like so:
MacVim有很棒的配色方案,你仍然可以像这样从终端启动它:
$ mvim file.txt
That will open your file in a new Vim window.
这将在新的 Vim 窗口中打开您的文件。
回答by robince
@ashcatch - Can't leave a comment, but wanted to add that iTerm has other advantages over Terminal.app such as sensible copy and paste (configurable 'word' regex for easy double click selection of paths/urls, middle click paste) and terminal mouse support (:se mouse=a in vi to get mouse text selection, moving of window borders etc.)
@ashcatch - 无法发表评论,但想补充一点,iTerm 与 Terminal.app 相比具有其他优势,例如合理的复制和粘贴(可配置的“word”正则表达式,可轻松双击路径/网址,中键粘贴)和终端鼠标支持(vi 中的:se mouse=a 用于获取鼠标文本选择、窗口边框的移动等)
I'd be lost without it.
没有它我会迷路的。