Home >Backend Development >Golang >Why isn't Go Syntax Highlighting Working in VIM?
Adding Go Syntax Highlighting to VIM
Problem:
Despite following the official documentation, syntax highlighting for Go language is not working in VIM.
Answer:
Update:
With the release of Go 1.4, the official Go support for various editors, including VIM, has been removed from the repository.
Original Instructions:
Create a go.vim file in ~/.vim/ftdetect with the following content:
au BufRead,BufNewFile *.go set filetype=go
Alternative Installation Method:
The provided instructions are no longer valid due to the removal of official Go support. However, here is an alternative method:
Install the vim-go plugin from the Vim Package Manager (Vundle):
Plugin 'fatih/vim-go'
Add the following lines to your .vimrc file:
" Set the Go runtimepath set runtimepath+=$GOROOT/bin:$GOROOT/misc/vim " Enable Go syntax highlighting syntax enable " Enable Go filetype detection filetype plugin indent on
Note: The plugin method provides a more stable and feature-rich solution for Go syntax highlighting in VIM.
The above is the detailed content of Why isn't Go Syntax Highlighting Working in VIM?. For more information, please follow other related articles on the PHP Chinese website!