维姆,怎么装语法突显

当我在 Vim 中执行 Rmodel、 Rcontroller 和其他命令时,我只看到白色文本。 但是当我转到下一个缓冲区,然后返回到 :bn:bl,颜色正在工作。

这是我的.vim 文件夹 Https://github.com/regedarek/dotvim

27463 次浏览

Try:

:e

If you have no unsaved changes to the file.

Or:

:syn off | syn on

Use :syntax sync fromstart

I got that tip from http://vim.wikia.com/wiki/Fix_syntax_highlighting

That article also suggests creating a mapping for that command e.g. to map F12:

noremap <F12> <Esc>:syntax sync fromstart<CR>
inoremap <F12> <C-o>:syntax sync fromstart<CR>

Try:

:Rrefresh!

This command refresh certain cached settings and also reload rails.vim.
It's help me refresh syntax highlighting in Rails.

Another option is:

doautocmd Syntax

Sometimes syntax is OK, but all that is getting broken are foldings. In that case zx helps alot.

From VIM documentation:

zx

Update folds: Undo manually opened and closed folds: re-apply 'foldlevel', then do "zv": View cursor line. Also forces recomputing folds. This is useful when using 'foldexpr' and the buffer is changed in a way that results in folds not to be updated properly.

Tried all the above - none worked for me.

The only thing that does work is: :filetype detect so I remapped a quick shortcut :noremap <Leader>,ftd :filetype detect

You can also try:

CTRL-L

From the VIM docs (:h CTRL-L):

Clear and redraw the screen. The redraw may happen later, after processing typeahead.