Index

Table of contents

fugitive

homepage
https://github.com/tpope/vim-fugitive
call a git command
:Git [command]
:G   [command]
example: call git status
:Git status
:G   status
delete buffer and delete file from git
:GDelete
move a file and update git index and buffer name
:GMove
show diff of current file with last commit
:Gdiffsplit
:Gvdiffsplit
load the current file, 3 commits ago
:Gedit HEAD~3:%
git grep
:Ggrep

git summary window

open git summary window
:Git
git summary key bindings
[n]gs   jump to [n]'th staged file
[n]gu   jump to [n]'th unstaged or untracked file
[n]gU   jump to [n]'th unstaged file

o       open file in split
gO      open file in vertical split (capital O)
<cr>    open file

a       toggle file staged/unstaged
s       stage file
u       unstage file
U       unstage everything
X       discard changes for file (git checkout)

ca      amend commit
cc      create commit
ce      amend commit without changing message
cs      create squash commit
cA      create squash commit and change message
cS      create squash commit and immediately rebase
cw      reword last commit

=       toggle inline diff
dd      show diff in horizontal split
dh      show diff in horizontal split
dv      show diff in vertical split
visual mode
-    toggle staging of selected files

git log

show git log
:Git log
check out commit under cursor
coo

textob-word-column

homepage
https://github.com/coderifous/textobj-word-column.vim/blob/master/doc/textobj-word-column.txt
new motions
ac    select whole column based on |aw|
ic    select whole column based on |iw|
aC    select whole column based on |iw|
iC    select whole column based on |iW|
usage
ctrl-v [motion]

surround

homepage
https://github.com/tpope/vim-surround
normal mode
cs"'           change surrounding " with '
cs'"           change surrounding ' with "
cs"(           change surrounding ' with (...)
cs"<i>         change surrounding " with <i>...</i>
cst"           change surrounding <tag> with "

ds'            delete surrounding '
ds"            delete surrounting "
ds(            delete surrounding '
dst            delete surrounting <tag>

ys{motion}'    surround motion with '
ys{motion}"    surround motion with "
ys{motion}(    surround motion with (...)
ys{motion}<b>  surround motion with <b>...</b>
visual mode
S'             surround motion with '
S"             surround motion with "
S(             surround motion with (...)
S<u>           surround motion with <u>...</u>

commentary

homepage
https://github.com/tpope/vim-commentary
toggle current line commented out
gcc
toggle motion commented out
gc{motion}
uncomment current line and any adjacent lines commented out
gcgc

emmet

homepage
https://github.com/mattn/emmet-vim.git
http://emmet.io/

config

change emmet leader key (default = ctrl-y)
let g:user_emmet_leader_key='<C-p>'
run emmet only for certain vim modes
let g:user_emmet_mode='n'    "only enable normal mode functions.
let g:user_emmet_mode='inv'  "enable all functions, which is equal to
let g:user_emmet_mode='a'    "enable all function in all mode.
run emmet for snippet
<leader>,

emmet syntax

html 5 template
html:5
create an element
div
...
<div></div>
create nested elements
div>ul>li
...
<div>
	<ul>
		<li></li>
	</ul>
</div>
create sibling
div+div
...
<div></div>
<div></div>
climb up levels using ^
table>tr>td>span>a^b^^tr>td>p
...
<table>
	<tr>
		<td>
			<span><a href=""></a></span>
			<b></b>
		</td>
	</tr>
	<tr>
		<td>
			<p></p>
		</td>
	</tr>
</table>
repeat an element with *
table>tr*3>td*2
...
<table>
	<tr>
		<td></td>
		<td></td>
	</tr>
	<tr>
		<td></td>
		<td></td>
	</tr>
	<tr>
		<td></td>
		<td></td>
	</tr>
</table>
add an id with #
div#one
...
<div id="one"></div>
adding a class with .
div.emphasis
...
<div class="emphasis"></div>
adding an attribute with []
div[empty]
...
<div empty=""></div>

div[data-foo=bla]
...
<div data-foo="bla"></div>

div[data-foo="bla"]
...
<div data-foo="bla"></div>
generating numbered values for * with $
ul>li#id$*3
...
<ul>
	<li id="id1"></li>
	<li id="id2"></li>
	<li id="id3"></li>
</ul>

ul>li.number$*3
...
<ul>
	<li class="number1"></li>
	<li class="number2"></li>
	<li class="number3"></li>
</ul>

ul>li.number$$$*3
...
<ul>
	<li class="number001"></li>
	<li class="number002"></li>
	<li class="number003"></li>
</ul>
reverse numbering with @-
ul>li#id$@-*3
...
<ul>
	<li id="id2"></li>
	<li id="id1"></li>
	<li id="id0"></li>
</ul>
custom starting value
ul>li#id$@9*3
...
<ul>
	<li id="id9"></li>
	<li id="id10"></li>
	<li id="id11"></li>
</ul>

ul>li#id$@-9*3
...
<ul>
	<li id="id11"></li>
	<li id="id10"></li>
	<li id="id9"></li>
</ul>
add text to element with {...}
p{bla bla bla}
...
<p>bla bla bla</p>

nerdtree

homepage
https://github.com/preservim/nerdtree
generate help files
vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q
toggle quick help on/off
?
close nerdtree
q

navigating

moving in the tree
p                   jump to parent of current node
shift-p             move cursor to tree root
ctrl-k              previous sibling
ctrl-j              next sibling
shift-k             first sibling
shift-j             last sibling
opening and closing nodes
o                   open / close selected directory node
shift-o             open tree recursively
shift-x             recursively close the children of the current node
shift-c             current node become nerdtree root
u                   up one level (jump to parent node of current root node)
shift-u             up one level, as with u, but keep expanded
r                   refresh selected directory
shift-r             refresh full tree
cd                  change cwd to the selected directory
shift-c, shift-d    use cwd as the nerdtree root node
change view
f                   toggle file filters
shift-f             toggle files
shift-i             toggle show hidden files

editing files

open selected file
o
<enter>
open selected file in split pane
i          horizontal split
s          vertical split
gi         horizontal split preview (nerdtree stays visible and slected)
gs         vertical split preview (nerdtree stays visible and slected)
file actions
m          show menu
ma         add file (or directory if it ends with a slash '/')
md         delete selected noce
mo         open node in system editor
mp         copy path to clipboard
mr         open node in system file manager