Giraffa-vim can build a vim-plugin-based environment for golang. It will install and configure YouCompleteMe, vim-go and some other plugins.
It allows you to search and replace words, comment and uncomment codes.
It allows you to jump to definition recusively.
It allows you to format codes with gofmt
.
Ubuntu 16.04
Ubuntu 18.04
CentOS 7
Giraffa-vim supports only vim 8.
Execute ./check.sh
to check if the environment is suitable for the installation.
Execute ./install.sh
to do the installation.
a) As some Golang tools will be installed while executing ./install.sh
, you need to make sure that the environment variables of Golang are configured correctly before this installation. Here is my ~/.bashrc
:
export GOROOT=/usr/local/go
export GOPATH=`$GOROOT/bin/go env GOPATH`
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
b) Golang has some issue in China, so if you are in China, please pay attention to the yes-or-no questions while installing.
c) go env -w GO111MODULE=auto
or go env -w GO111MODULE=on
may be necessary to enable <F12>
.
Execute source ~/.bashrc
after the installation to make vimc
work.
To start a go project, execute vimc
at the root of the project.
:Q<CR>
: quit vim and all plugins
:W<CR>
: save all & :Q<CR>
<C-k>
: save
\tg
: open or close the window of taglist
<F5>
: go to shell, equivalent to :term<CR>
gg=G
: format the current file with gofmt
mh
: move cursor to left window
mj
: move cursor to bottom window
mk
: move cursor to top window
ml
: move cursor to right window
mw
: move cursor to window below/right of the current one
mt
: move cursor to top-left window
mb
: move cursor to bottom-right window
mp
: move cursor to previous window
+
: increase width of window towards left
-
: decrease width of window towards right
\cc
: comment one line
\cv
: comment one line with next delimiter
\cm
: comment multi lines
\c$
: comment to end of line
\cu
: uncomment
<C-p>
: search file in project
:Grep [keyword]<CR>
: search the keyword in project
\vv
: search the word under cursor in project
:Replace [keyword]<CR>
: replace the word under cursor with keyword
in project
:Replace [target] [keyword]<CR>
: replace the word target
with keyword
in project
:UndoReplace<CR>
: undo :Replace
cgt
: save changes and close all tabs except the first, then close the bottom-right window
:ccl<CR>
: close Grep
window
\'
: wrap selected part by "'", if no part is selected, the word under cursor will be wrapped
\\'
: remove the closest "'" wrapped the part in which the cursor is
similar shortcuts: \"
and \\"
, \(
and \\(
, \[
and \\[
, \{
and \\{
, \<
and \\<
<F12>
: goto definition
<C-o>
: go backword
<C-i>
: go forward
:GoDebugStart .<CR>
: run debugger of vim-go
<C-j>
: move cursor backwards out of parenthesis
<C-k>
: goto normal mode and save
<C-e>
: move the current character to the end of next word
<C-l>
: move the cursor to the end of line
<C-\>
: delete the word under the cursor
To get more information about usage, click on the links at the References below.
vim -Nu ~/.vim/bundle/YouCompleteMe/vimrc_ycm_minimal xxx.go
to get minimal vim configuration for YCM to debug YCM.- Debug commands of YCM:
:YcmDiags
,YcmDebugInfo
,YcmToggleLogs
.
https://github.com/VundleVim/Vundle.vim
https://github.com/Valloric/YouCompleteMe
https://github.com/preservim/nerdtree
https://github.com/fatih/vim-go
https://github.com/ctrlpvim/ctrlp.vim
https://github.com/scrooloose/nerdcommenter
https://github.com/majutsushi/tagbar
https://github.com/rstacruz/sparkup
https://github.com/Yggdroot/indentLine
https://github.com/jiangmiao/auto-pairs
https://github.com/tpope/vim-repeat
https://github.com/tpope/vim-fugitive
https://github.com/Xuyuanp/nerdtree-git-plugin
https://github.com/YvesZHI/vim-code-dark
https://github.com/YvesZHI/killersheep
https://github.com/goproxy/goproxy.cn
https://codeyarns.com/2015/03/18/how-to-test-color-setup-in-vim