vim vimrc 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
nav 0 to line beginning $ to line end ^ to first non-space character on the line g_ to last non-space character on the line gg to first line G to last line g; to last edit 12G to line 12 Ctrl + e scroll one line down Ctrl + y scroll one line up H to viewport h ead M to viewport m iddle L to viewport bottom
word nav w to next w ord’s beginning e to next word’s e nd b to previous word’s b eginning ge to previous word’s end
substitution command mode:
:s/meat/veggies/g sub "meat" with "veggies" in a line :%s/meat/veggies/g sub in all lines :16,18s/meat/veggies/g sub in lines 16–18
search /mieu search forward for "mieu" ?mieu search backward for "mieu" /\cmieu search for "mieu" and ignore cases /\<mieu\> search for "mieu" exactly
misc commands :w save, w rite changes to file :update save only if there are changes :x ex it :q q uit
modes normal x cut a character dd cut a line daw cut current word with spaces yy copy line y$ copy to line’s end yiw copy current word sans spaces p paste after P paste before gp paste after and move cursor after pasted text u u ndoCtrl + r r edoCtrl + a increase number (on cursor) Ctrl + x decrease number (on cursor)
insert i insert at cursor a insert after cursor (a ppend) I insert at current line’s start A insert at current line’s end o insert new line below current line O insert new line above current line s delete character under cursor S delete all text on line cw delete to current word’s end C delete from cursor to line’s end
visual v highlight V highlight line Ctrl + v highlight block d d elete (cut)y y ank (copy)p p ut (paste)