Skip to content

Instantly share code, notes, and snippets.

@DrGo
Last active September 26, 2019 10:38
Show Gist options
  • Save DrGo/7256f19221472d90ecba44f2c4a0dd7e to your computer and use it in GitHub Desktop.
Save DrGo/7256f19221472d90ecba44f2c4a0dd7e to your computer and use it in GitHub Desktop.
Vim for Go

Vim for Go development

Vim-go

motions

  • if : select the code inside a function
  • af : select the entire function code including comments

shortcuts

  • gd : go to definition of word under cursor
  • Ctrl-O / Ctrl-I :hop back to your source file/return to definition
  • K : opens documentationn

commands

:GoRun :GoBuild :GoInstall
:cn :cp # goto next/previous problem in the issues window :GoDef # goto definition of object under cursor
:GoDoc # open documentation

:GoTest # run every *_test.go file and report results
:GoTestFunc # or just test the function under your cursor
:GoCoverage # check your test coverage
:GoAlternate # switch bewteen your test case and implementation

:GoImport # manage and name your imports
:GoImportAs
:GoDrop

:GoRename # precise renaming of identifiers

:GoLint # lint your code
:GoVer
:GoErrCheck

YouComplete me

install

  • compile the c++ server
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --clangd-completer --go-completer

settings

" close autocomplete window when done
let g:ycm_autoclose_preview_window_after_completion=1

" disable tab use so tab can be used to complete snippets
let g:ycm_key_list_select_completion=[]
let g:ycm_key_list_previous_completion=[]

tpope/vim-dispatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment