vim

| delimitMate | autocompletion of quotes, parentheses, brackets, etc. |
| NERDTree | tree explorer |
| airline | status bar |
| gitgutter | git diff, hunk staging and preview |
| goyo | distraction-free writing mode |
| move | move lines and selections |
| plug | plugin manager |
| wiki | personal wiki |
osseus
Osseus loads templates (stored in ~/.osseus/) into vim. It works 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\+$//eReload .vimrc on save
au! BufWritePost .vimrc so ~/.vimrcI also use a similar command to the one above to rebuild Arachne after saving a .tome. ara build here is just a shell script.
au! BufWritePost *tome :silent !ara build > /dev/nullReturn to last edit position
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endifTurn current word into HTML tag
imap <C-t> <></><Esc>5hdiwp3lpT>iStart vim in edit mode immediately:
vim '+ normal GA' +startinsert file.txtnav
| 0 | to line start |
| $ | 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 head |
| M | to viewport middle |
| L | to viewport bottom |
word nav
| w | to next word’s beginning |
| e | to next word’s end |
| b | to previous word’s beginning |
| ge | to previous word’s end |
substitution
command mode:
:s/chard/silverbeet/g | sub chardwith silverbeetin a line |
:%s/chard/silverbeet/g | sub in all lines |
:16,18s/chard/silverbeet/g | sub in lines 16–18 |
search
/mieu | search forward for mieu |
?mieu | search backward |
/\cmieu | search and ignore cases |
/\<mieu\> | search for exact match |
misc
commands
:w | save, write changes to file |
:update | save only if there are changes |
:x | exit |
:q | quit |
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 | undo |
| Ctrl + r | redo |
| Ctrl + a | increase number (on cursor) |
| Ctrl + x | decrease number (on cursor) |
insert
| i | insert at cursor |
| a | insert after cursor (append) |
| 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 | delete (cut) |
| y | yank (copy) |
| p | put (paste) |
resources
- Effective VimScript by
Martin Tournoij - Seven habits of effective text editing by
Bram Moolenaar - Vim anti-patterns by
Tom Ryder - Vim scripting cheatsheet
- Vim Tips Wiki
- :help