avatar

vim

vim interface
vimrc
plugins
delimitMateautocompletion of quotes, parentheses, brackets, &c.
NERDTreetree explorer
vim-airlinestatus bar
vim-gitguttergit diff, hunk staging and preview
goyodistraction-free writing mode
vim-movemove lines and selections
vim-plugplugin manager
vim-wikipersonal wiki

osseus

I have this little setup dubbed “Osseus” that allows me to load templates (stored in ~/.osseus/) into vim. It works in tandem with dmenu and can be summoned with <leader>m.

function Osseus(template)
  :1,$d
  execute ':read ' . '~/.osseus/' . a:template
endfunction

function OsseusMenu()
  :1,$d
  :read ! cat ~/.osseus/$(ls -1 ~/.osseus | dmenu)
endfunction

nmap <leader>m :call OsseusMenu()<CR>

bits

Purge trailing whitespace on save

au BufWritePre 1 %s/\s\+$//e

Reload .vimrc on save

au! BufWritePost .vimrc so ~/.vimrc

Return to last edit position

au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif

Turn current word into an HTML tag

imap <C-t> <></><Esc>5hdiwp3lpT>i

Start vim in edit mode immediately:

vim '+ normal GA' +startinsert file.txt
0to line beginning
$to line end
^to first non-space character on the line
g_to last non-space character on the line
ggto first line
Gto last line
g;to last edit
12Gto line 12
Ctrl + escroll one line down
Ctrl + yscroll one line up
Hto viewport head
Mto viewport middle
Lto viewport bottom

word nav

wto next word’s beginning
eto next word’s end
bto previous word’s beginning
geto previous word’s end

substitution

command mode:

:s/meat/veggies/gsub "meat" with "veggies" in a line
:%s/meat/veggies/gsub in all lines
:16,18s/meat/veggies/gsub in lines 16–18
/mieusearch forward for "mieu"
?mieusearch backward for "mieu"
/\cmieusearch for "mieu" and ignore cases
/\<mieu\>search for "mieu" exactly

misc

commands

:wsave, write changes to file
:updatesave only if there are changes
:xexit
:qquit

modes

normal

xcut a character
ddcut a line
dawcut current word with spaces
yycopy line
y$copy to line’s end
yiwcopy current word sans spaces
ppaste after
Ppaste before
gppaste after and move cursor after pasted text
uundo
Ctrl + rredo
Ctrl + aincrease number (on cursor)
Ctrl + xdecrease number (on cursor)

insert

iinsert at cursor
ainsert after cursor (append)
Iinsert at current line’s start
Ainsert at current line’s end
oinsert new line below current line
Oinsert new line above current line
sdelete character under cursor
Sdelete all text on line
cwdelete to current word’s end
Cdelete from cursor to line’s end

visual

vhighlight
Vhighlight line
Ctrl + vhighlight block
ddelete (cut)
yyank (copy)
pput (paste)

resources