"语法启用"仅适用于普通模式,而不适用于vimrc

时间:2017-12-14 18:19:51

标签: vim

不知道我是怎么打破我的vimrc,但我有。我安装了日光浴,但语法高亮不再自动工作 - 我必须重新输入"语法启用"每次我打开编辑器。

我的vimrc在下面 - 任何帮助非常感谢!

" ----- BASICS  -----
set nocompatible "compatible with vi
if !exists("g:syntax_on") 
    syntax enable
endif

filetype on "QS not sure about this one ! 
set number "add line numbers
set showcmd "show command in bottom bar
set cursorline "highlight cursor line
set wildmenu "commandline tab completion 
set mouse=a "make vim useable with mouse
set backspace=indent,eol,start " make backspace work like in most editors.
set showmatch           " highlight matching [{()}]

" ----- COLORSCHEME -----
let g:solarized_termcolors = 256 
set background=light
colorscheme solarized

    " ------ NAVIGATION -----
" long line navigation in normal mode
nnoremap j gj 
nnoremap k gk

" ------ TABS & SPACES -----
set tabstop=4        "number of visual spaces per TAB
set shiftwidth=4 "size of indent with tab
set softtabstop=0 
set noexpandtab "if you are using tab character inside your source
"code - these are defensive settings to avoid conversion

" ---------Searching ----------
set incsearch           " search as characters are entered
set hlsearch            " highlight matches

" ----------Folding ----------- 
set foldenable          " enable folding
set foldlevelstart=10   " open most folds by default
set foldnestmax=10      " 10 nested fold max
nnoremap <space> za     
"space open/closes folds
set foldmethod=indent   " fold based on indent level

set smartindent         " indents your code automatically 
filetype off                  " required

1 个答案:

答案 0 :(得分:1)

~/.vimrc中的最后一行禁用文件类型检测。如果没有它,Vim会将每个打开的文件视为纯文本,因此不会加载任何语法插件。放弃那条线,没有意义。

filetype off                  " required

为了从内置的文件类型和缩进插件中受益,而不是打开所有内容:

filetype plugin indent on

有关详细信息,请参阅:help :filetype