MacVim从〜/ .vimrc获取所有设置,但不是颜色,我必须再次获取它

 手机用户2602927807 发布于 2023-02-03 02:34

我在MacOS X Mavericks上使用以下〜/ .vimrc和MacVim 7.4:

set guifont=Menlo:h14
set encoding=utf8
set mouse=a
set expandtab
set ts=8
set showcmd
set nocompatible
set backspace=2
set viminfo='20,\"50
set history=50
set ruler
set si
set hlsearch
syntax on
set bg=light
hi Cursor     term=inverse   ctermfg=black                guifg=black  guibg=green
hi Visual     term=inverse   ctermfg=yellow ctermbg=black guifg=yellow guibg=black
hi Comment    term=inverse   ctermfg=grey   ctermbg=black guifg=white  guibg=black
hi Identifier term=NONE      ctermfg=black                guifg=black
hi Constant   term=underline ctermfg=darkred              guifg=red
hi Statement  term=bold      ctermfg=blue                 guifg=blue
hi PreProc    term=NONE      ctermfg=black                guifg=black  gui=underline
hi Special    term=NONE      ctermfg=black                guifg=black
hi Type       term=bold      ctermfg=blue                 guifg=blue

并且可以看到编辑器从该文件中获取所有设置(字体系列及其大小,显示标尺和选项卡设置,......),但不是颜色:

截图1

只有在我发出命令后:so ~/.vimrc,它才会采用我的颜色设置(红色和蓝色,反转注释):

截图2

请问有谁知道,发生了什么,为什么MacVim也没有采用语法颜色?

以下是:version信息:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 10 2013 18:40:52)
MacOS X (unix) version
Compiled by Douglas Drumond 
Huge version with MacVim GUI.  Features included (+) or not (-):
+arabic          +emacs_tags      +localmap        +postscript      +textobjects
+autocmd         +eval            -lua             +printer         +title
+balloon_eval    +ex_extra        +menu            +profile         +toolbar
+browse          +extra_search    +mksession       +python          +transparency
++builtin_terms  +farsi           +modify_fname    -python3         +user_commands
+byte_offset     +file_in_path    +mouse           +quickfix        +vertsplit
+cindent         +find_in_path    +mouseshape      +reltime         +virtualedit
+clientserver    +float           +mouse_dec       +rightleft       +visual
+clipboard       +folding         -mouse_gpm       +ruby            +visualextra
+cmdline_compl   -footer          -mouse_jsbterm   +scrollbind      +viminfo
+cmdline_hist    +fork()          +mouse_netterm   +signs           +vreplace
+cmdline_info    +fullscreen      +mouse_sgr       +smartindent     +wildignore
+comments        -gettext         -mouse_sysmouse  -sniff           +wildmenu
+conceal         -hangul_input    +mouse_urxvt     +startuptime     +windows
+cryptv          +iconv           +mouse_xterm     +statusline      +writebackup
+cscope          +insert_expand   +multi_byte      -sun_workshop    -X11
+cursorbind      +jumplist        +multi_lang      +syntax          -xfontset
+cursorshape     +keymap          -mzscheme        +tag_binary      +xim
+dialog_con_gui  +langmap         +netbeans_intg   +tag_old_static  -xsmp
+diff            +libcall         +odbeditor       -tag_any_white   -xterm_clipboard
+digraphs        +linebreak       +path_extra      -tcl             -xterm_save
+dnd             +lispindent      +perl            +terminfo
-ebcdic          +listcmds        +persistent_undo +termresponse
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-p
ragmas -pipe  -DMACOS_X_UNIX -no-cpp-precomp  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE
=1
Linking: clang   -L.    -L.     -L/usr/local/lib -o Vim -framework Cocoa -framework Carb
on       -lncurses  -liconv -framework Cocoa   -fstack-protector -L/usr/local/lib  -L/Sy
stem/Library/Perl/5.12/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -framework
Python   -framework Ruby

romainl.. 14

的MacVim是采购其默认gvimrc 您的~/.vimrc.它包含以下代码段:

" Load the MacVim color scheme.  This can be disabled by loading another color
" scheme with the :colorscheme command, or by adding the line
"   let macvim_skip_colorscheme=1
" to ~/.vimrc.
if !exists("macvim_skip_colorscheme") && !exists("colors_name")
    colorscheme macvim
endif

发生的事情很简单::hi当您启动Vim时,MacVim的默认colorscheme会覆盖您的命令,并且您的:hi命令会在您获取源时覆盖默认的colorscheme ~/.vimrc.

修复也很简单::hi按照Ingo的回答将命令转换为真正的颜色方案.

此外,set background=light仅在colorscheme中有用,因此也可以移动该行.

2 个回答
  • 的MacVim是采购其默认gvimrc 您的~/.vimrc.它包含以下代码段:

    " Load the MacVim color scheme.  This can be disabled by loading another color
    " scheme with the :colorscheme command, or by adding the line
    "   let macvim_skip_colorscheme=1
    " to ~/.vimrc.
    if !exists("macvim_skip_colorscheme") && !exists("colors_name")
        colorscheme macvim
    endif
    

    发生的事情很简单::hi当您启动Vim时,MacVim的默认colorscheme会覆盖您的命令,并且您的:hi命令会在您获取源时覆盖默认的colorscheme ~/.vimrc.

    修复也很简单::hi按照Ingo的回答将命令转换为真正的颜色方案.

    此外,set background=light仅在colorscheme中有用,因此也可以移动该行.

    2023-02-03 02:57 回答
  • 这不是一个直接的答案,但你应该将你的所有:hi命令提取~/.vimrc到一个单独的(私有)colorscheme中,例如~/.vim/colors/mine.vim.前面加上以下序言:

    hi clear
    if exists("syntax_on")
        syntax reset
    endif
    let g:colors_name = "mine"
    

    然后选择colorscheme via

    :colorscheme mine
    

    在你的~/.vimrc.

    优点

    应该解决你的问题.

    使用Vim提供的正确抽象.

    减少您的尺寸.vimrc,使其更易于管理.

    允许您即时切换颜色方案.

    暂时转动时恢复颜色:syntax off.

    2023-02-03 03:18 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有