Home  >  Article  >  Backend Development  >  How do I Enable GoLang Syntax Highlighting in VIM with Go 1.4 and Later?

How do I Enable GoLang Syntax Highlighting in VIM with Go 1.4 and Later?

Barbara Streisand
Barbara StreisandOriginal
2024-11-15 08:32:02348browse

How do I Enable GoLang Syntax Highlighting in VIM with Go 1.4 and Later?

Add GoLang Syntax Highlighting for VIM

You're looking to set up GoLang syntax highlighting for VIM. While the instructions you're following are generally correct, they no longer apply to the latest Go distributions.

Update:

Go 1.4 and later no longer include Go support files for editors. This information has been moved to a curated wiki page.

Solution:

Instead of the instructions you found at http://go-lang.cat-v.org/text-editors/vim/, follow these steps:

  1. Open your .vimrc file.
  2. Add the following lines:
" Clear filetype flags before changing runtimepath to force Vim to reload them.
filetype off
filetype plugin indent off
set runtimepath+=$GOROOT/misc/vim
filetype plugin indent on
syntax on
  1. Save and close .vimrc.

Note that you may need to adjust the path to $GOROOT/misc/vim depending on your installation. Once you've completed these steps, GoLang syntax highlighting should be enabled in VIM.

The above is the detailed content of How do I Enable GoLang Syntax Highlighting in VIM with Go 1.4 and Later?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn