Vim Notes

Cheatsheat

Windows & Tabs

Maximize/Minimize window using tabs: :tab sp :tab close

Key Action
C-w _ Maximize horizontal split
C-w = Equlize all splits
C-w | Maximize vertical split
C-w r Swap splits
C-w o Close everything else
C-w m Maximize/Minimze*

Spelling

[s: search for misspelled words above the cursor
]s: search for misspelled words below the cursor
z=: see replacement suggestions
zg: add the word to your dictionary

Miscellaneous

Substitute multi-line pattern:

:%s/^START.\{-}\_.\{-}END$/replace/g

Compress multiple blank lines:

:g/^$/,/./-j

Tags

Search tags:

:ts <tag><TAB>
g] Search tag under cursor
<Ctrl-T> rewind tag stack

TODO: Need a mapping for :Tags in the wiki (preferably using )

Keybinding Thoughts

XXX: Don’t forget Shift/C/M+Arrows

Text Objects

:help objects
a(, a), ab / i(, i), ib
a"/i"
a'/i'

Namespaces

:help g
:help [
:help z

Useless Commands

gs

EASLRB Vim Notes

Convert old anchors:

:%s/NAME="a\(.\{-}\)_\(.\{-}\)"/NAME="\1.\2"/gc

Add anchors to paragraph:

:%s/<P><B>\(.\{-}\)\(\s\+\)<I>/<P><A NAME="\a"><\/A><B>\1\2<I>/gc

Add <em> tags to exceptions:

:%s#\(\[EXC:.\{-}\_.\{-}\]\)#<em class="exception">\1</em>#gc

Convert links to new folder structure:

:%s#href="\(.\)\(.\{-}\)htm#href="../chap_\1/\1\2htm#gc
NOTE: This ends up as chap_X, not chap_x

Other

Stuff to look at

:help gq (formatprg)
:help = (equalprg)
:help path
:help wildmode
:help wildmenu
:help *
Ctrl-N : insert mode completion based on file contents
Macros
:help abbr (:abbr teh the)
:help smarttab (might be able to indent with tabs and align with spaces)
http://vimcasts.org/blog/2013/11/registers-the-good-the-bad-and-the-ugly-parts/
https://github.com/romainl/idiomatic-vimrc

Config ideas

(https://gist.github.com/romainl/4b9f139d2a8694612b924322de1025ce) (https://learnvimscriptthehardway.stevelosh.com/) (https://github.com/plasticboy/vim-markdown) (https://github.com/vim-pandoc/vim-pandoc-syntax) (https://github.com/vim-pandoc/vim-pandoc:w) (https://github.com/svermeulen/vim-easyclip) (https://github.com/lifepillar/vim-mucomplete) (https://github.com/lambdalisue/fern.vim) Copy/Paste to system clipboard: (https://stackoverflow.com/questions/11489428/how-to-make-vim-paste-from-and-copy-to-systems-clipboard)

Custom highlight groups

https://gist.github.com/romainl/58245df413641497a02ffc06fd1f4747

    highlight IsModified    ctermbg=red
    highlight IsNotModified ctermbg=green

    Dynamic status line:
    set statusline+=%#IsModified#%{&mod?expand('%'):''}%*%#IsNotModified#%{&mod?'':expand('%')}%*
                   \______________ Part A _____________/\______________ Part B ________________/
    The &?: construct seems similar to ?: in C

Undo

set undofile    " keep an undo file (undo changes after closing)
set undodir
set undolevels
set undoreload
gundo.vim?

Plugins