我是vim的新手,我想在vim中编码。我已经在TypeScript中安装了语法高亮JSX的必要插件,一切都适用于Vim的GUI版本,但不适用于基于终端的Vim。请帮我弄明白这个问题。下面是我用于语法高亮的插件。
我正在使用Vundle来安装插件。我尝试用上面提到的第二个插件的README部分中给出的颜色进行一些自定义。根据当我使用hi
命令时,它对基于终端的Vim没有任何影响,但它在基于GUI的Vim上工作得非常好。另外,如果可能的话,请指向我的任何文章/博客,以便初学者了解更多有关vim和vimscript的信息。
编辑:
我正在尝试在TypeScript for React Development中为JSX设置语法高亮,我已经安装了上面的插件来实现这一点。以下是我的.vimrc文件的内容。
set nocompatible " choose no compatibility with legacy vi syntax enable
set encoding=utf-8
set showcmd " display incomplete commands
set t_Co=256
filetype plugin indent on " load file type plugins + indentation
"" monkai theme
syntax enable
colorscheme monokai
set nu
set guifont=monacob\ bold\ 9
highlight ColorColumn ctermbg=gray
set colorcolumn=80
"" Whitespace
set nowrap " don't wrap lines
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
set expandtab " use spaces, not tabs (optinal)
set backspace=indent,eol,start " backspace through everything in insert mode
"" Searching
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
" set the runtime path to include Vundle and initialize
set rtp +=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive.git'
Plugin 'tpope/vim-rails'
Plugin 'leafgarland/typescript-vim'
Plugin 'peitalin/vim-jsx-typescript'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" autocmd FileType typescript.tsx setlocal commentstring={/*\ %s\ */}
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescript.tsx
autocmd BufNewFile,BufRead *.ts,*.js set filetype=typescript.jsx
" dark red
hi tsxTagName guifg=#E06C75
" orange
hi tsxCloseString guifg=#F99575
hi tsxCloseTag guifg=#F99575
hi tsxAttributeBraces guifg=#F99575
hi tsxEqual guifg=#F99575
" yellow
hi tsxAttrib guifg=#F8BD7F cterm=italic
正如我们在.vimrc和截图中看到的那样,在文件末尾声明的JSX标签颜色等对Gvim工作正常,但不适用于基于终端的vim。请帮我理解我在这里做错了什么。
" dark red hi tsxTagName guifg=#E06C75
使用guifg
属性,您只需为GVIM定义颜色。
从Vim 8开始,就有了:help 'termguicolors'
选项;你可以尝试:set termguicolors
;一些终端确实支持这一点。
如果不这样做,你必须通过:set t_Co?
/ ctermfg
属性分别定义颜色终端的颜色(来自有限的调色板,具体取决于可用颜色的数量,ctermbg
会告诉你)。例如:
hi tsxTagName guifg=#E06C75 ctermfg=DarkRed
像CSApprox这样的插件可以采用GUI颜色定义并将它们转换为紧密匹配的256色cterm
调色板,用于高色终端。这有助于使用颜色方案,否则只从平淡的默认16色终端调色板中选择,或仅提供GUI颜色定义。
csexact采用了另一种方法,它修改了(支持的)终端的调色板,使其与Vim的GUI颜色完全匹配。