This is an overview of features of vim that I find are useful. I do not describe them in detail. This has already
been made (and much better than I could do so) in the help files that come with vim.
Support for Sessions
|Store a session into the file mySession, so It can be used the next day.
|Load (source) yesterday's session.
vim -S mySession
|alternative way to source mySession
|What needs to be stored with :mksession and what doesn't|
Support for Views
|Store the currentview into file mySession
|Have vim determine the file (use :loadview when file re-opened)
|Store up to 9 configurations per file
|Get the view stored with :mkview myView|
Maps are a powerful features that recognizes specific sequences of keys and does something that
would require more key presses. For example, I might define a map that is just rn and whenever
type rn, it is expanded to my email adress.
|Check if a specific map already exists|
|Fills spaces when using the tabulator
|Shows tabs as <- when using :list
More detailled help with :help options.txt. Get a table with a quick explanation on each option with :help Q_op.
Per File type basis
|Tell me what autocommand groups exist
|Enables file type detection, by reading $VIMRUNTIME/filetype.vim.
This file defines many, many autocommands,
for example |
au BufNewFile,BufRead *.pl setf perl
Setting Options for a particular File
It's possible to set options for a specific file by including a line at the beginning of that
file like this:
// vim: shiftwidth: 44. When the file containing such a line is opened, the
shiftwidth for that file is set to 44. Note that only set commands are allowed in order to
prevent trojan horses.
|Enable the feature, don't forget :set modelines=xxx
|Check the first five lines in a file for vim: |
gvim -u NONE -U NONE foo.txt
|Don't read no stinky .vimrc, .gvimrc , and plugin files|
|Defines a function, function's first letter must be capitalized, end function with endfunction|
exe "normal iString"
|Prepend typing in Normal Mode|
|Substituting in a function|
|Ask for foo, assign to i|
|Fileformat (end of line)|
|Useful for macros: the screen will not be redrawn if a macro is running.|
|If pressed in command mode: pops up a window to edit the history|
|:g/^/exec "s/^/".line(".")||Replacing start of line with line number|
Built in functions
|Expands file names (for example expand("*.txt"). There are also modifiers that allow to extract parts of file names. expand("%:e") gives
the extension of the file currently edited. Getting the name under the cursor:
|Return current line number|
|Return current column|
By no means is this an exhuaustive list of string functions. I merly want to to have the ones
that are not necessarly clear if coming from another language.
==? ==# =~ !~
|Equal ignoring case, really equal, regex match, regex fail
The global command
The following global command deletes 10 lines before a line containing My search strin.
:g/My search string/-10,.d