Enable Vim Syntax Highlighting By Default

后端 未结 6 1454
死守一世寂寞
死守一世寂寞 2020-12-07 14:07

I know how to turn syntax highlighting on and off in vim by running this in the editor:

:syntax on/off

But I want syntax highlighting to be

6条回答
  •  失恋的感觉
    2020-12-07 14:58

    Edit your $HOME/.vimrc (Unix/Linux/OSX) or $HOME/_vimrc (Windows) to include the following line:

    syntax on
    

    EDIT

    If your syntax highlighting doesn't work when you start Vim, you probably don't have a $HOME/.vimrc or $HOME/_vimrc (known collectively as vimrc from now on). In that case, you have two options:

    • Create an empty vimrc.
    • Copy vimrc_example.vim as your vimrc (recommended, thanks @oyenamit). You can find vimrc_example.vim in the runtime directory.

    The location of the runtime directory varies between operating systems:

    • On my system (Arch Linux, and Mac, thanks @totophe), it's in /usr/share/vim/vim73.
    • On Windows, it's in \Program Files\Vim\vim73.

提交回复
热议问题