Home >Backend Development >Golang >Why isn't Go syntax highlighting working in Vim after installing go.vim?

Why isn't Go syntax highlighting working in Vim after installing go.vim?

Susan Sarandon
Susan SarandonOriginal
2024-11-12 19:29:02767browse

Why isn't Go syntax highlighting working in Vim after installing go.vim?

Configuring Go Syntax Highlighting in Vim

Attempting to add Go syntax highlighting to Vim, you followed the instructions to copy go.vim to the syntax directory and create a ftdetect file. However, the highlighting is not activating.

Solution

As per the Go 1.4 Release Notes, Go support for editors like Vim has been removed from the standard repository. Instead, you can find installation instructions for Vim plugins on the Go Wiki:

To use all the Vim plugins, add these lines to your $HOME/.vimrc.

" Some Linux distributions set filetype in /etc/vimrc.
" 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

Update your .vimrc file with these lines, and Vim will automatically load the necessary syntax settings for Go files.

The above is the detailed content of Why isn't Go syntax highlighting working in Vim after installing go.vim?. 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