.vimrcThis is personal. I’m not taking notes of things I already memorized.
The commands are usually composed of a verb and a noun. Example: dw, stands for delete a word.
Tip: usually the same key used two times in a row applies the verb in the whole line. Examples: dd deletes the whole line, cc change the whole line.
See :h motion for more info.
| mapping | summary |
|---|---|
f<char> |
(f)ind a char forward in a line and move to it (F goes backward) |
t<char> |
find a char forward in a line and move un(t)il it (T goes backward) |
; |
repeat last f, F, t or T command |
, |
repeat last f, F, t or T command, but in opposite direction |
H, M, L |
move (H)igh, (M)iddle, or (L)ow within the viewport |
C-u, C-d |
move (u)p or (d)own |
Tip: prefer using text-objects rather than motions in order to increase repeatability.
See :h text-objects for more options.
| mapping | operation |
|---|---|
iw, aw |
“inner word”, “a word” (a word includes the space) |
is, as |
“inner sentece”, “a sentece” |
ip, ap |
“inner paragraph”, “a paragraph” |
i), a) |
“inner parenthesis”, “a parenthesis” |
i', a' |
“inner single quote”, “a single quote” |
it, at |
“inner tag”, “a tag” (HTML tag) |
:set nu or :set number - line numbers
:set ai | :set noai - enable/disable autoindent
:set visualbell - blink screen instead of sound
:ab md mydomain.intranet.com - when you type md it becomes mydomain.intranet.com
visualy select part of the text and :'<,'>$!sort - sort the lines
:noh - disables search highlight
set a default font in gvim: :set guifont=*, choose the font config in the dialog box, then use :set guifont? to see what you should put in your .vimrc.
colorscheme evening
set number
set tabstop=2
set showcmd
set cursorline " gutter
Avoid too much configurations, but take a look at this one (which claims to be “defaults everyone can agree on”): https://github.com/tpope/vim-sensible
It enables things like <C-L> to clear hlsearch, <C-W> to delete previous word when in INSERT mode, etc.
The vim-plug is useful to install/update vim plugins.
Here’s a way to install it at startup:
.vimrc
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
Syntax of the language: Verb + Noun
Example:
Some verbs:
d: deletec: change (delete and enter insert mode)>: indentv: visually selecty: yank (copy)Some nouns related to motions:
w: wordb: back2j: down 2 linesSome nouns related to text objects:
iw: inner word (works from anywhere in a word)it: inner tag (the contents of an HTML tag)i": inner quotesip: inner paragraphas: a sentenceSome nouns related to parameterized text objects
f, F: find the next character, including it.t, T: find the next character, excluding it./, ?: search the string, not including the string.:set relativenumberds": delete surrounding quotescs(": change surrounding parens to quotesysiw": add double quotes around the wordcst<h2>: change surrounding tag to <h2>Questions to be answered:
.md extension when creating a new wiki page with <Enter>?:w?mynotes)