简体   繁体   English

vimrc-语法突出显示不起作用

[英]vimrc - Syntax highlighting not working

so this is what my .vimrc contains, why is my syntax highlighting not working? 所以这是我的.vimrc包含的内容,为什么我的语法高亮显示不起作用?

set nocompatible " must be the first line
filetype plugin indent on
syntax on
set laststatus=2
set statusline=%<%f\%h%m%r%=%-20.(line=%l\ \ col=%c%V\ \ totlin=%L%)\ \ \%h%m%r%=%-40(bytval=0x%B,%n%Y%)\%P
set nu
set shortmess=I
set nowrap
set tabstop=2
set backspace=indent,eol,start
set shiftwidth=2
set shiftround
set ignorecase
set smarttab
set hlsearch
set incsearch
set undolevels=1000
set pastetoggle=<F2>
set t_Co=256
colorscheme monokai
let g:user_emmet_leader_key = '<c-y>'
execute pathogen#infect()
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd vimenter * NERDTree

My color theme works, but the colors are not showing up properly as syntax highlighting. 我的颜色主题有效,但是颜色不能正确显示为语法突出显示。

Any suggestions? 有什么建议么?

First, check the output of: 首先,检查以下内容的输出:

:setlocal syntax?

The correct output (for php files) is: 正确的输出(对于php文件)为:

syntax=php

You can check the php syntax code doing a: 您可以执行以下操作检查php语法代码:

:syntax list

You must see all syntax code with the command above. 您必须使用上面的命令查看所有语法代码。 If you don't get the syntax=php value or don't see any syntax code on :syntax list , probably you don't have a php.vim file in your ~/.vim/ftplugin folder. 如果您没有得到syntax=php值或在:syntax list上看不到任何语法代码,则~/.vim/ftplugin文件夹中可能没有php.vim文件。 When you set filetype plugin on and open an php file, what Vim does is to look in your ftplugin folder for a php.vim file and execute it. 当您将filetype plugin on设置为打开并打开一个php文件时,Vim所做的就是在ftplugin文件夹中查找php.vim文件并执行它。

php.vim is a system file, and it comes with the default installation. php.vim是系统文件,它带有默认安装。 Try to do a :scriptname to see all scripts that are opening with vim. 尝试使用:scriptname查看所有以vim打开的脚本。 If you can't see a php.vim file, a solution could be install StanAngeloff/php.vim plugin. 如果看不到php.vim文件,则可以安装StanAngeloff / php.vim插件作为解决方案。

If, and only if, you have a php.vim file and see its syntax with :syntax list , then something external is affecting Vim's syntax highlight, and it's probably your terminal. 当且仅当您有一个php.vim文件,并使用:syntax list查看其语法时,外部因素才影响Vim的语法突出显示,并且可能是您的终端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM