gd
jumps to the definition of a type, variableC-t
jumps you back to where you where.- Use
<tab>
to autocomplete snippets in insert mode. Example snippets. :A
open alternate (i.e. test for current file). Also:AH
and:AV
for horizontal and vertical splits.gt
will run the tests for the current file.:GoDeclsDir
will show all functions in current directory.K
open GoDoc for symbol under the cursor.<leader>i
over a function or method name will show function information.<leader>c
will run GoCoverage for the current file.<leader>m
will run the GoMetaLinter for the current file.:GoReferrers
will find anything calling the function under the cursor.:GoRename
will allow you rename any symbol in the package.
- While editing:
:so %
:edit
Reload current file
- http://naleid.com/blog/2010/10/04/vim-movement-shortcuts-wallpaper/
>>
and<<
for indenting textJ
Join next line with current lineC-f
Forward a pageC-b
Back a page#
Find word under cursor<leader>space
Clear search0
Go to start of line<number>j
/<number>j
Move number of lines down/up_
Go to the start of the first word on the line
:enew
Open no name buffer in the current windowu
UndoC-R
Redoe
Jump to end of word (inc. puncuation)O
Insert line before (and go to edit mode)o
Insert line after (and go to edit mode)cs"'
Change quotes (that's c, s, double quote, single quote)vi<surrounding>p
Replace 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 commandD
Delete until end of line in normal modeC
Change until the end of the line in normal modeyg_
Copy to end of line excluding line break~
Change case of single character under cursor
ir
andar
are used for a block, e.g.vir
if
andaf
for a function, e.g.vif
orcif
ic
,ac
for a class, e.g.cic
an
for a name, e.g.cin
for something likeMyName::Project
- Once selected
o
will jump between start and end of selected block
<leader>ci
to toggle comments on lines- https://github.com/tpope/vim-commentary
gcc
Comment out a linegc
Comment 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>v
Vertical split<leader>h
Horizontal splitC-<direction>
Navigate windows<leader>ww
Swap buffers between windows (https://github.com/wesQ3/vim-windowswap)C-w
thenq
Close the currently selected split:on
Close all splits except the current selection
:ls
List buffers:b <name>
Tab complete buffer name:bn
Next buffer:bp
Previous bufferC-6
Previous buffer<leader>b
Previous buffer:bd
Delete current buffer
gt
Next tabgT
Previous tabZZ
Write and close a tab
q
Close window<direction>
Move up/down the listo
Opent
Open as tabv
Open as vertical spliti
Open as horizontal split
C-p
Open Search DialogueC-d
Only match file namesEsc
Close DialogueC-j
C-k
Navigate resultsC-o
Choose how to open (vertical split etc.)Enter
Open result
\
Search shortcut:Ag -i <pattern>
for a literal search (use quotes if there are spaces in the search term)K
Search for word under cursor:%s/search/replace/
:%s/star/blackhole/gic
Confirm each replacement (global, case-insensitive, confirm)SHIFT-3
Match 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.vimrc
to help it find the tags.C-]
Jump to 'tag' under cursorC-t
Jump back to previous tag<leader>.
Search ctags file using Ctrl-P
:OpenGithubFile
Open current file on Github:Gitv
Open Git explorerGlog -- %
Commits that touched the current file:Gblame
Run Git blame on the current file:Gstatus
Status:Glog
To view log then]Q
to go to start of list and]q
to step through revisions:Gedit
to revert to working copy:Glog -10
Last 10 revisions
RunTests
Runs mspec test for the current fileRunNearestTest
Runs mspec test for current testruby % --line 57
http://www.brianstorti.com/vim-registers/
:reg <register> <register>
List register contents"0p
Paste previously pasted content:let @+=@%
Copy current file path to clipboard