我遇到了以下命令的问题:
autocmd FileType go autocmd BufWritePre <buffer> Fmt
它应该会在我.vimrc
文件的结尾自动格式化我的代码。
这是我的 .vimrc
文件的样子:
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
Plugin 'user/L9', {'name': 'newL9'}
Plugin 'commentary.vim'
Plugin 'go.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
syntax on
filetype plugin on
filetype indent on
"autocmd FileType go compiler go
autocmd FileType go autocmd BufWritePre <buffer> Fmt
然而,vim给我抛出了一个错误信息:
Error Detected while processing BufWrite Auto commands for "" E492: Not an editor command: Fmt
我不知道出了什么问题,尤其是因为它之前是可以工作的。
$GOROOT/misc/vim
中已经包含的插件和 readme.txt 文件中的说明有什么不同呢? - Charlie Parker:Fmt
命令吗?如果有,那么就不会有问题;如果没有,那么就会有问题。(nsf/gocode 似乎没有:Fmt
命令) - FDinoff