VIM v19-03-05 Update
A short summary of my daily used VIM commands.
homepage documentation manual reference faq wiki
Ben McCormick - Learning Vim
Bram Moolenaar - Seven habits of effective text editing
Ben McCormick - Vim as Language
TutorialsPoint - Vim Tutorial
STEP | TOPIC | COMMANDS |
---|---|---|
01 | tutorial | $ firefox vim-adventures.com & $ vimtutor |
02 | documentation | $ man vim $ firefox file:///usr/share/doc/vim-doc/html/index.html & :help user-manual • ^] ^o :help edit ^d :helpgrep |
03 | buffer | $ ^xe :edit $ vim -O ~/.vimrc ~/.bashrc ^ww ^wr ^wc ^wq $ vim ~/.bashrc ~/.bashrc :args :ls :next :previous :n :N :buffers :badd :b1 :b2 :bn :bp :bf :bl |
04 | cursor | H M L zt zz zb z<enter> z- l h j k |
05 | insert | i I s S a A o O C |
06 | window | :set nu nonu :set relativenumber norelativenumber :set hls nohls * :set ruler noruler :set linebreak nolinebreak ^ws ^wv ^wr ^wc ^wq gg G ^g 50% ^e ^y ^n ^u ^d ^f ^b |
07 | repeat | . |
08 | macro | qa :reg a @a |
09 | search | / f * # :set incsearch :nhls |
10 | change | ~ :%s/one/two/g :set hls <enter> * cw n :set nohls <enter> ci( ci{ ci< |
11 | delete | x d$ diw dit di" dip das |
12 | undo redo | u U ^r |
13 | match | [InsertMode] ^n |
14 | abbreviate | :ab :abc :unab ^v |
15 | mark | m1 '1 `1 marks |
16 | fold | zf5j zo zc zd |
17 | visual | v ^v |
18 | text objects | iw it i" ip as f F t T / |
99 | buffer | :wq :q! |
i : Insert text before the cursor.
I : Insert text before the first non-blank in the line.
s : Delete character under the cursor and start insert mode.
S : Delete line and start insert mode.
a : Enter insert mode after cursor.
A : Enter insert mode at the end of the line.
o : Enter insert mode on the next line.
O : Enter insert mode on th above line.
C : Delete from cursor to end of line and begin insert.
iw : inner word
it : inner tag
i" : inner quotes
ip : inner paragraph
i{ : inner brackets
as : a sentence
f,F
t,T
/
:ab psvm public static void main(String[] args) {<CR>}<Esc>ko
:ab sysout System.out.println("");<Esc>2hi
^v : deaktivate ab
EDITOR=/usr/bin/vim
VISUAL=$EDITOR
export EDITOR VISUAL
syntax on syntax off
set incsearch noincsearch
set nu nonu
set showmode noshowmode
set showcmd noshowcmd
set relativenumber norelativenumber
set ruler noruler
set hls nohls
set background=dark
set encoding=utf8
set mouse=a
set autoindent
set tabstop=3
set softtabstop=3
set shiftwidth=3
set expandtab
nmap <leader>w :w!<cr>
map <F2> :echo 'Current time is ' . strftime('%c')<CR>
map <F6> :setlocal spell! spelllang=en_us<CR>
:ab psvm public static void main(String[] args) {<CR>}<Esc>ko
:ab sysout System.out.println("");<Esc>2hi
# apt-get install vim vim-doc vim-scripts
$ dpkg -L vim-doc
# update-alternatives --config editor
$ vim --version | less