VIM-Linux Basic

模式转换

常用的两种模式就是普通模式和插入模式
Normal Mode进入Insertion Mode

a //=append
i //=insert
esc //go back to Normal Mode

delete

d   //delete selected
dd  //delete the whole line
    //or CUT actually, you can "p" paste it

n dd //delete n lines (down)

dj  //j directs downwards , so delete current line and the one later

D   //delete from cursor to END of line

d^  //delete till bengining of line

dG   //delete to END OF FILE

d1G  //to beginning of file


dw   //delete a word删除一个单词
dnw  //delete n words

x  //delete a letter
nx //delete n letters

普通模式下的命令

.   //repeate last operation重复上一次操作

gg  //to begining of file
G   //to end line of line

set nu  //显示行号
n G     //goto nth line跳转到第n行

ctrl o  //回到上一次的游标地址

## copy&paste ##

y   //copy what's been selected

yy  //copy the whole line

yw  //copy a word

ynw  //copy n words

y^/y0   //copy to begining of line
y$     //copy to end

p   //粘贴到光标这一行之后
P   //粘贴到光标这一行之前

## replace ##

r<..>   //replace cursor with input
R <..>  //esc to stop
cc      //delete whole line & replace
cw      //replace a word

~  //反转大小写capslock

u   //undo once
un  //undo n times
U   //undo all operations on current line
ctrl+r  //redo what you undo

## 缩进&排版 ##

<<  //shift what've been selected left
>>  //shift selected right

ce  //居中center
le  //left
ri  //right

## find ##

/<word> //向下查找word
?<word> //向上查找

n   //next, 继续原来方向查找下一个
N   //反方向查找下一个

VISUAL MODE

v       //进入选择模式,每次选择一个字符
shift V //select a whole line
ctrl v  //select a block

//the same to end select

多文件编辑

vim 1.txt 2.txt //create&open several files

n               //edit next file
N               //edit former file

e filename      //open new file

e#              //back to last file

ls              //list edited files

f                   //show file name
f newname filename  //rename

set instructions

set nu  //显示行号
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值