vim中的语法高亮根本不起作用

时间:2018-04-07 15:16:50

标签: vim

我一直忙于在thisthis源的帮助下将vim配置为IDE,但我似乎无法使语法突出显示起作用。

在我的~/.vimrc我有以下两个设置filetype plugin indent onsyntax on,它们应该突出显示语法,但每当我打开文件(例如Javascript)时,它都不起作用

当我打开文件并执行:syntax list时,我得到以下回复:No syntax items defined for this buffer

我(快速)在互联网上搜索并参考我提到的设置(并且被正确定义)。

我缺少什么?

在我的整个.vimrc内容

之下
set nocompatible

"""" Config Vundle plugin manager """""
filetype off

set rtp=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'

"""" Plugins """"
Plugin 'altercation/vim-colors-solarized'
Plugin 'tomasr/molokai'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'vim-syntastic/syntastic'
Plugin 'xolox/vim-misc'
Plugin 'xolox/vim-easytags'
Plugin 'majutsushi/tagbar'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'vim-scripts/a.vim'
Plugin 'airblade/vim-gitgutter'
Plugin 'tpope/vim-fugitive'
Plugin 'Raimondi/delimitMate'
Plugin 'jez/vim-superman'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'jez/vim-c0'
Plugin 'jez/vim-ispc'
Plugin 'kchmck/vim-coffee-script'
Plugin 'godlygeek/tabular'
Plugin 'HTML-AutoCloseTag'
Plugin 'ekalinin/Dockerfile.vim'
Plugin 'cakebaker/scss-syntax.vim'
Plugin 'tpope/vim-surround'
Plugin 'ntpeters/vim-better-whitespace'
Plugin 'edkolev/tmuxline.vim'

"""" OSX stupid backspace fix """"
set backspace=indent,eol,start

call vundle#end()
filetype plugin indent on
syntax on

"""" General settings """"
set backspace=indent,eol,start
set ruler
set number
set showcmd
set incsearch
set hlsearch

"""" Set tabs """"
set tabstop=2
set shiftwidth=2
set smarttab
set expandtab

"""" Enable mouse support """"
set mouse=a

"""" Enable highlighting of the current line """"
set cursorline

"""" Support symbols in the title bar """"
hi clear SignColumn

"""" Colorscheme (Solarized) """"
set background=dark
colorscheme solarized

" Always show statusbar
set laststatus=2

"""" Enable Menlo font """"
let g:airline_powerline_fonts = 1

" Show PASTE if in paste mode
let g:airline_detect_paste=1

" Show airline for tabs too
let g:airline#extensions#tabline#enabled = 1

" Use the solarized theme for the Airline status bar
let g:airline_theme='solarized'

"""" Nerdtree config """"
" Open/close NERDTree Tabs with \t
nmap <silent> <leader>t :NERDTreeTabsToggle<CR>
" To have NERDTree always open on startup
let g:nerdtree_tabs_open_on_console_startup = 1

"""" Scrooloose/syntastic settings """"
let g:syntastic_error_symbol = '✘'
let g:syntastic_warning_symbol = "▲"
augroup mySyntastic
  au!
  au FileType tex let b:syntastic_mode = "passive"
augroup END

"""" Easytags settings """
set tags=./tags;,~/.vimtags
" Sensible defaults
let g:easytags_events = ['BufReadPost', 'BufWritePost']
let g:easytags_async = 1
let g:easytags_dynamic_files = 2
let g:easytags_resolve_links = 1
let g:easytags_suppress_ctags_warning = 1

"""" Tagbar settings """"
" Open/close tagbar with \b
nmap <silent> <leader>b :TagbarToggle<CR>
" Open tagbar automatically whenever possible
autocmd BufEnter * nested :call tagbar#autoopen(0)

"""" Vimgutter settings """
" In vim-airline, only display "hunks" if the diff is non-zero
let g:airline#extensions#hunks#non_zero_only = 1

"""" delimitMate settings """
let delimitMate_expand_cr = 1
augroup mydelimitMate
  au!
  au FileType markdown let b:delimitMate_nesting_quotes = ["`"]
  au FileType tex let b:delimitMate_quotes = ""
  au FileType tex let b:delimitMate_matchpairs = "(:),[:],{:},`:'"
  au FileType python let b:delimitMate_nesting_quotes = ['"', "'"]
augroup END

"""" Superman config """"
noremap K :SuperMan <cword><CR>

修改

低于vim --version

的回复
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)
Included patches: 1-503, 505-680, 682-1283
Compiled by root@apple.com
Normal version without GUI.  Features included (+) or not (-):
+acl             +file_in_path    -mouse_sgr       +tag_old_static
-arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           -mouse_urxvt     -tcl
-balloon_eval    +folding         +mouse_xterm     -termguicolors
-browse          -footer          +multi_byte      -terminal
+builtin_terms   +fork()          +multi_lang      +terminfo
+byte_offset     -gettext         -mzscheme        +termresponse
+channel         -hangul_input    +netbeans_intg   +textobjects
+cindent         +iconv           +num64           +timers
-clientserver    +insert_expand   +packages        +title
-clipboard       +job             +path_extra      -toolbar
+cmdline_compl   +jumplist        -perl            +user_commands
+cmdline_hist    -keymap          +persistent_undo +vertsplit
+cmdline_info    +lambda          +postscript      +virtualedit
+comments        -langmap         +printer         +visual
-conceal         +libcall         -profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             -rightleft       +windows
+diff            +menu            +ruby/dyn        +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
-emacs_tags      -mouseshape      +startuptime     -xpm
+eval            -mouse_dec       +statusline      -xsmp
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_clipboard
+extra_search    -mouse_jsbterm   +syntax          -xterm_save
-farsi           -mouse_netterm   +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa

编辑2

我现在注意到,当我尝试重新加载.vimrc文件时,出现以下错误:

Error detected while processing /usr/share/vim/vim80/syntax/syntax.vim:
line   42:
E216: No such group or event: filetypedetect BufRead

pointsdirection改变了runtimepath值{{3}},但我没有在任何地方定义。我已经尝试将其添加到我的.vimrc,但重新加载后仍然会出现相同的错误。

我把它放在文档的顶部(就在set nocompatible之后,所以也许这个位置可能是问题,但如果是的话,我应该把它放在哪里呢?

2 个答案:

答案 0 :(得分:6)

Damnit,我在第6行错过了+个字符

设置set rtp=~/.vim/bundle/Vundle.vim应该是set rtp+=~/.vim/bundle/Vundle.vim。现在它有效!

答案 1 :(得分:0)

在修改更新Cells()时,请确保您:source ~/.vimrc成功无错误。

执行source vimrc的步骤:

  1. ~/.vimrc
  2. 输入vim ~/.vimrc
  3. 输入