gdjumps to the definition of a type, variableC-tjumps you back to where you where.- Use
<tab>to autocomplete snippets in insert mode. Example snippets. :Aopen alternate (i.e. test for current file). Also:AHand:AVfor horizontal and vertical splits.gtwill run the tests for the current file.:GoDeclsDirwill show all functions in current directory.Kopen GoDoc for symbol under the cursor.<leader>iover a function or method name will show function information.<leader>cwill run GoCoverage for the current file.<leader>mwill run the GoMetaLinter for the current file.:GoReferrerswill find anything calling the function under the cursor.:GoRenamewill allow you rename any symbol in the package.
- While editing:
:so % :editReload current file
- http://naleid.com/blog/2010/10/04/vim-movement-shortcuts-wallpaper/
>>and<<for indenting textJJoin next line with current lineC-fForward a pageC-bBack a page#Find word under cursor<leader>spaceClear search0Go to start of line<number>j/<number>jMove number of lines down/up_Go to the start of the first word on the line
:enewOpen no name buffer in the current windowuUndoC-RRedoeJump to end of word (inc. puncuation)OInsert line before (and go to edit mode)oInsert line after (and go to edit mode)cs"'Change quotes (that's c, s, double quote, single quote)vi<surrounding>pReplace into surround chars from clipboardyss<character>Surround a while line with the particular character (e.g. quotes)ci<character>Change text within=Indent selected lines.Repeat previous commandDDelete until end of line in normal modeCChange until the end of the line in normal modeyg_Copy to end of line excluding line break~Change case of single character under cursor
irandarare used for a block, e.g.virifandaffor a function, e.g.viforcific,acfor a class, e.g.cicanfor a name, e.g.cinfor something likeMyName::Project- Once selected
owill jump between start and end of selected block
<leader>cito toggle comments on lines- https://github.com/tpope/vim-commentary
gccComment out a linegcComment out a block in visual mode
- https://github.com/junegunn/vim-easy-align
- Select some lines in visual mode and press
<Enter>then<char_to_align_on> - Use
ga<some_selection><char_to_align_on>, e.g.gai{=
<leader>vVertical split<leader>hHorizontal splitC-<direction>Navigate windows<leader>wwSwap buffers between windows (https://github.com/wesQ3/vim-windowswap)C-wthenqClose the currently selected split:onClose all splits except the current selection
:lsList buffers:b <name>Tab complete buffer name:bnNext buffer:bpPrevious bufferC-6Previous buffer<leader>bPrevious buffer:bdDelete current buffer
gtNext tabgTPrevious tabZZWrite and close a tab
qClose window<direction>Move up/down the listoOpentOpen as tabvOpen as vertical splitiOpen as horizontal split
C-pOpen Search DialogueC-dOnly match file namesEscClose DialogueC-jC-kNavigate resultsC-oChoose how to open (vertical split etc.)EnterOpen result
\Search shortcut:Ag -i <pattern>for a literal search (use quotes if there are spaces in the search term)KSearch for word under cursor:%s/search/replace/:%s/star/blackhole/gicConfirm each replacement (global, case-insensitive, confirm)SHIFT-3Match all under cursor:CtrlSF <pattern>then in window do a search replace as per above and save it to save changes to all files.
ctags -R --exclude=.git --exclude=log *Generate tags for this project.set tags=./tags;Add to.vimrcto help it find the tags.C-]Jump to 'tag' under cursorC-tJump back to previous tag<leader>.Search ctags file using Ctrl-P
:OpenGithubFileOpen current file on Github:GitvOpen Git explorerGlog -- %Commits that touched the current file:GblameRun Git blame on the current file:GstatusStatus:GlogTo view log then]Qto go to start of list and]qto step through revisions:Geditto revert to working copy:Glog -10Last 10 revisions
RunTestsRuns mspec test for the current fileRunNearestTestRuns mspec test for current testruby % --line 57
http://www.brianstorti.com/vim-registers/
:reg <register> <register>List register contents"0pPaste previously pasted content:let @+=@%Copy current file path to clipboard