command line, text-editor

vim cheatsheet

Most useful commands to get familiar with powerful text editor. There is great tutorial available, just type vimtutor in console.

Movement 

e           go to end of the current word
b           go to beginning of the current word
⇧ + $       go to an end of the current line
⇧ + ^       go to beginning of the current line
gg          go to beginning of the file
⇧ + q       go to end of the file

Searching

/           enter search (forward) mode
?           enter search (back) mode
n           next occurrence

General

u           undo
o           open new line below and go to insert mode
⇧ + o       open new line above and go to insert mode
%           jump to corresponding bracket
:q          quit
⇧ + ZZ      write changes & quit
⇧ + ZQ      quit without saving changes

Text manipulation

x           delete character being under cursor
r           replace a single character being under cursor
c + e       remove all chars from cursor to an end of given word
c + b       remove all chars from cursor to beginning of the given word 
c3e         remove next 3 words
5dd         remove next 5 lines
ci{         remove all content in between brackets
*           highlight all occurrences of a current word
⇧ + v       mark whole line
v           mark a custom selection
yy          copy whole line
y           copy selection
d           cut selection
p           paste below
⇧ + p       paste above

~/.vimrc

:set nocompatible    use the newest features
:set number          line numbers.
:set incsearch       live search
:set hlsearch        highlight search occurrences
:set autoindent      auto indent in code
:syntax on           syntax highlightning
:set mouse=a         enable mouse