这是我的问题:
vim /etc/file.toml
,其语法高亮显示有人知道如何解决这个问题吗?缓存问题?
注意:几乎每个文件扩展名都会出现此问题,我不切换用户(总是root)。
答案 0 :(得分:0)
尝试在.vimrc中设置syntax enable
而不是syntax on
。
直接来自:h syntax
This command switches on syntax highlighting: >
:syntax enable
What this command actually does is to execute the command >
:source $VIMRUNTIME/syntax/syntax.vim
If the VIM environment variable is not set, Vim will try to find
the path in another way (see |$VIMRUNTIME|). Usually this works just
fine. If it doesn't, try setting the VIM environment variable to the
directory where the Vim stuff is located. For example, if your syntax files
are in the "/usr/vim/vim50/syntax" directory, set $VIMRUNTIME to
"/usr/vim/vim50". You must do this in the shell, before starting Vim.
*:syn-on* *:syntax-on*
The ":syntax enable" command will keep your current color settings. This
allows using ":highlight" commands to set your preferred colors before or
after using this command. If you want Vim to overrule your settings with the
defaults, use: >
:syntax on
阅读Here了解详情。
编辑:经过一些研究后,我发现如果上述方法不起作用,那是因为该特定文件类型的文件类型插件会覆盖用户设置。要解决此问题,您可以在home vim文件夹中创建一个名为after
的新文件夹。 after
中的每个文件都来自/usr/share/vim74
中的任何文件。 after
的结构必须与vim74文件夹文件夹的结构匹配。
为了方便起见,我写了一个快速的脚本
#!/usr/bin/bash
# Make the after folders you need
mkdir -p $HOME/.vim/after/ftplugin
# Create the Global Settings file for syntax highlighting and formatting options
touch $HOME/.vim/after/fo_globals.vim
# Create links to the fo_globals file
for file in /usr/share/vim/vim74/ftplugin/*.vim
do
ln -s $HOME/.vim/after/fo_globals.vim $HOME/.vim/after/ftplugin/`basename $file`
done
然后使用语法和格式选项填写您的globals文件。我看起来像这样。
syntax enable
set formatoptions-=c
set formatoptions-=r
set formatoptions-=o
set autoindent
set smartindent
set nocindent
set backspace=indent,eol,start
set expandtab
set tabstop=4
set shiftwidth=4
set shiftround