github.com/spotify/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/misc/vim/readme.txt (about) 1 Vim plugins for Go (http://golang.org) 2 ====================================== 3 4 To use all the Vim plugins, add these lines to your $HOME/.vimrc. 5 6 " Some Linux distributions set filetype in /etc/vimrc. 7 " Clear filetype flags before changing runtimepath to force Vim to reload them. 8 filetype off 9 filetype plugin indent off 10 set runtimepath+=$GOROOT/misc/vim 11 filetype plugin indent on 12 syntax on 13 14 If you want to select fewer plugins, use the instructions in the rest of 15 this file. 16 17 A popular configuration is to gofmt Go source files when they are saved. 18 To do that, add this line to the end of your $HOME/.vimrc. 19 20 autocmd FileType go autocmd BufWritePre <buffer> Fmt 21 22 23 Vim syntax highlighting 24 ----------------------- 25 26 To install automatic syntax highlighting for GO programs: 27 28 1. Copy or link the filetype detection script to the ftdetect directory 29 underneath your vim runtime directory (normally $HOME/.vim/ftdetect) 30 2. Copy or link syntax/go.vim to the syntax directory underneath your vim 31 runtime directory (normally $HOME/.vim/syntax). Linking this file rather 32 than just copying it will ensure any changes are automatically reflected 33 in your syntax highlighting. 34 3. Add the following line to your .vimrc file (normally $HOME/.vimrc): 35 36 syntax on 37 38 In a typical unix environment you might accomplish this using the following 39 commands: 40 41 mkdir -p $HOME/.vim/ftdetect 42 mkdir -p $HOME/.vim/syntax 43 mkdir -p $HOME/.vim/autoload/go 44 ln -s $GOROOT/misc/vim/ftdetect/gofiletype.vim $HOME/.vim/ftdetect/ 45 ln -s $GOROOT/misc/vim/syntax/go.vim $HOME/.vim/syntax 46 ln -s $GOROOT/misc/vim/autoload/go/complete.vim $HOME/.vim/autoload/go 47 echo "syntax on" >> $HOME/.vimrc 48 49 50 Vim filetype plugins 51 -------------------- 52 53 To install one of the available filetype plugins: 54 55 1. Same as 1 above. 56 2. Copy or link ftplugin/go.vim to the ftplugin directory underneath your vim 57 runtime directory (normally $HOME/.vim/ftplugin). Copy or link one or more 58 additional plugins from ftplugin/go/*.vim to the Go-specific subdirectory 59 in the same place ($HOME/.vim/ftplugin/go/*.vim). 60 3. Add the following line to your .vimrc file (normally $HOME/.vimrc): 61 62 filetype plugin on 63 64 65 Vim indentation plugin 66 ---------------------- 67 68 To install automatic indentation: 69 70 1. Same as 1 above. 71 2. Copy or link indent/go.vim to the indent directory underneath your vim 72 runtime directory (normally $HOME/.vim/indent). 73 3. Add the following line to your .vimrc file (normally $HOME/.vimrc): 74 75 filetype indent on 76 77 78 Vim compiler plugin 79 ------------------- 80 81 To install the compiler plugin: 82 83 1. Same as 1 above. 84 2. Copy or link compiler/go.vim to the compiler directory underneath your vim 85 runtime directory (normally $HOME/.vim/compiler). 86 3. Activate the compiler plugin with ":compiler go". To always enable the 87 compiler plugin in Go source files add an autocommand to your .vimrc file 88 (normally $HOME/.vimrc): 89 90 autocmd FileType go compiler go 91 92 93 Godoc plugin 94 ------------ 95 96 To install godoc plugin: 97 98 1. Same as 1 above. 99 2. Copy or link plugin/godoc.vim to $HOME/.vim/plugin/godoc, 100 syntax/godoc.vim to $HOME/.vim/syntax/godoc.vim, 101 and autoload/go/complete.vim to $HOME/.vim/autoload/go/complete.vim.