vim - 为 VIM 添加 GoLang 语法高亮

标签 vim go vim-plugin vim-syntax-highlighting

我正在尝试将 Go 语言语法高亮添加到 ubuntu 上的 VIM,并在此处提供资源和方向 http://go-lang.cat-v.org/text-editors/vim/ .

Go 带有一个 go.vim 文件,其中包含 VIM 的语法设置,上面的页面提供了以下说明

将 $GOROOT/misc/vim/syntax/go.vim 放入 ~/.vim/syntax/并将以下内容放入 ~/.vim/ftdetect/go.vim:

au BufRead,BufNewFile *.go set filetype=go 

这或多或少与我在其他地方看到的自定义 vim 语法的过程相同 (Vim 7.3 on Ubuntu 12.10 doesn't have 'ftplugin' directory anywherehttps://github.com/jnwhiteh/vim-golang/blob/master/readme.txt)

所以我认为我在创建目录时做的是正确的事情:
~/.vim
~/.vim/语法
~/.vim/ftdetect

并按照上述说明添加

go.vim 到 ~/.vim/syntax/ 并在 ~/.vim/ftdetect/中创建一个文件 go.vim,其中包含

au BufRead,BufNewFile *.go set filetype=go

然而语法高亮似乎没有发生。我需要做些什么来强制 VIM 查看这些新的设置文件吗?

最佳答案

更新:

Go 1.4 Release Notes

Miscellany

The standard repository's top-level misc directory used to contain Go support for editors and IDEs: plugins, initialization scripts and so on. Maintaining these was becoming time-consuming and needed external help because many of the editors listed were not used by members of the core team. It also required us to make decisions about which plugin was best for a given editor, even for editors we do not use. The Go community at large is much better suited to managing this information. In Go 1.4, therefore, this support has been removed from the repository. Instead, there is a curated, informative list of what's available on a wiki page.


标准的 Go 发行版在 go/misc/vim/ 中包含 Vim 的 Go 文件。该目录包含一个 readme.txt 文件,其中包含安装说明。

readme.txt

Vim plugins for Go (http://golang.org)

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

If you want to select fewer plugins, use the instructions in the rest of this file.

<<..SNIP..>>

关于vim - 为 VIM 添加 GoLang 语法高亮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15579822/

相关文章:

Vim如何移动csv列

c - 换行符未出现在 proc 文件中

vim command + p like 查找文件命令

python - Go 中的 gRPC 服务器与 Python 中的客户端之间的兼容性

golang 反射(reflect)到 []interface{}

sockets - 使用 golang 从连接到网络接口(interface)的原始套接字读取

git - 如何让 Vim Ctrl-P 插件在 git 子模块中索引文件

vim - 如何将 Vim 重置为普通的 vanilla 安装?

ruby-on-rails - Vim/command-T : Ignoring "gem-name" because its extensions are not built. 尝试 gem pristine "gem-name"

Vim 中未启用 Python