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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值