The Vim on the server is horribly outdated. Many of the things below won’t work, or will require extensive setup. In order to ease the pain, I suggest using the version installed and maintained by Micha via the EBI-predoc config.
If you’re using this version of Vim, it will also already come with some plugins (notably YouCompleteMe) pre-configured. I haven’t tried this yet, though, so I don’t know how the configuration works for that.
hlsearch
,incsearch
,ignorecase
,smartcase
: More useful searchundofile
,undodir
: Infinite, persistent undo- NB: Requires up-to-date vim
autoread
,autowrite
: Automatically save & load file content after changelist
,listchars
: Show invisible charactersautocmd
: Perform action when condition is met (file loaded …)- E.g.
autocmd FileType make setlocal noexpandtab
- E.g.
{nvxsilc}{nore}map
: Map a key (combination) to something else- E.g.
nmap <leader>x :echo "Hello"<CR>
- E.g.
Apart from the trivial cursor movements (hjkl
):
g
: go somewhere[#]gg
,[#]G
: go to line # (default first / last)g0
,g^
,g$
: go to start / first non-blank character / end of line
H
,M
,L
: go to top / middle / bottom of screene
,w
,b
: Move to end of / beginning of next / beginning of previous wordf‹character›
,F‹character›
: go to next / previous ‹character› in line'
: go to marker''
: go to previous cursor location in filem‹letter›
: set marker ‹letter›'‹letter›
: go to marker ‹letter›
%
: go to matching brace / parenthesis(
,)
: go back / forth one sentence{
,}
: go up / down a paragraph
Movement commands can be combined with actions: d'a
deletes everything from
the current cursor position until the line designated by marker a
.
Movement commands can be prefixed by numbers: 7{
goes up seven paragraphs.
i
,a
: insert before / after cursorI
,A
: insert at start / end of lineo
,O
: insert new line after / before currentr‹character›
: replace selection with ‹character›v
,V
, Ctrl-V
: start (or stop) selection (“visual mode”) of characters / lines / vertical blockc
: change text of movement or selectionx
: delete characters of movement or selectiond
: delete characters of movement or selectiondd
,D
: delete whole line
>
,<
: indent, dedent movement or selection=
: re-indent movement or selection according to syntax rulesgq
: break lines of movement or selection after maximumtextwidth
y
: copy movement or selection into register (kind-of clipboard)yy
,Y
: copy whole line
p
,P
: paste register after / before cursor position/
,?
: search forward / backwardsn
,N
: go to next / previous hit
q‹letter›
,q
: start / stop recording of macro into register ‹letter›@‹letter›
: play back macro in register ‹letter›
J
: join next line to current
Remember: combine! 3>}
indents the rest of the paragraph by three tabs. gg=G
re-indents the whole file (start to end) using the current syntax rules.
These movements can be appended to an action command to denote a scope. For
instance, gq
(see above) breaks lines to limit them to textwidth
length.
gqap
applies this to a paragraph.
aw
,as
,ap
: select a word / a sentence / a paragraphab
ora(
: select a block in parenthesesaB
ora{
: select a block in bracesiw
,is
,ip
,ib
,i(
,iB
,i{
: like above, but stay inside the selection with cursor (e.g. don’t select the delimiting parentheses).
For instance, vi(p
replaces the content inside parentheses with the content of
the clipboard register.
- Vundle: Plugin package manager
- YouCompleteMe: The only auto completion you’ll ever need
- NB: Requires up-to-date vim
- r-plugin: Vim-R integration. R-Studio on ’roids.
- syntastic: On-the-fly code error checking
- ctrl-p: Full path fuzzy file finder
- vim-gitgutter: Shows version tracking changes in gutter
- vim-github: Github mirror of the Vim plugins
- Solarized: The One True™ colour scheme
Install via Vundle:
Bundle 'altercation/vim-colors-solarized'
. However, this has some issues in the terminal which are solved easiest by setting Solarized as the terminal’s colour scheme, in addition to Vim’s. The website contains detailed instructions on how to do this for each terminal emulator. - My dot-files, including my
.vimrc
- Exhaustive (!) Vim cheat sheet