vim preferences

How to use 4 spaces instead of tab in vim:

  1 :set ts=4

  2 :set number

  3 :set autoindent

  4 :set expandtab

  5 :set softtabstop=4

  6 :set shiftwidth=4


:set showmode
:set number
:set nonumber
:set ts=2 --------- display tab as 2 size(or add [:set ts=2] in ~/.vimrc, if not existing, just create one)

vim
========================================================
hjkl -------move cursor
x  ---------- remove character
dd ---------- cut whole line
Y/yy ---------- copy one line
nY ------------ copy n line
yG ------------ copy to the end of file
yw ------------ copy to the end of word(inline)
y$ ------------ copy to the end of line (inline)
P ------------- paste above/before
p ------------- paste below/after

J  ---------- join two lines
u  ---------- undo
Ctrl-R ---------- redo
U ------------undo whole line
a -------------append
o -------------insert new line under current row
O -------------insert new line above current row
9k
3x
ZZ -------------write and exit
:q! ------------exit without saving
:e! ------------reload file content
:help

gg ------------- go header
G -------------- go bottom
nG ------------- go n-th line below
H -------------- header
M --------------- middle
L --------------Last
Ctrl-G ----------tell where am i
Ctrl-U ---------- move up
Ctrl-D ---------- move down
Ctrl-E
Ctrl-Y
Ctrl-F
Ctrl-B
zz -------------- bring the current row to the middle of screen
zt -------------- to top
zb -------------- to bottom

/search
?search
n ------------next
N ------------opposite direction search

search and replace:
:<start-line>,<end-line>/<search-regex>/<replacement>/g
eg. :1,$s/[\t| ]*$//g  <---- remove all redundant tabs and whitespaces
or   :%s/[\t| ]*$//g    <---- %s equals 1,$s


猜你喜欢

转载自asran.iteye.com/blog/852185
Vim