VIM 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  //显示行号

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Vim几句话介绍Vim是Unix系统上的文本编辑软件(你该不会不知道什么是文本编辑软件吧!),在windows上也...
    何必遠方阅读 3,217评论 0 3
  • dpkg 学习 安装mysql apt-get install mysql-server-5.6 apt-get ...
    sharonji阅读 453评论 0 0
  • 命令历史 以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择某个历史命令。 启动vim 在命令...
    im蚂蚁阅读 30,836评论 3 48
  • 前段时间,关于限制外版童书引进的消息在业内引起了广泛讨论。一向热爱“八卦”的果麦麦并没有选择第一时间发声。这是因为...
    果麦文化阅读 1,765评论 1 0
  • 现在是凌晨4:02分,我依然未眠。不知道为什么,最近我总是整夜整夜睡不着,可能是太孤单,可能是有烦恼,可能是想法太...
    穿过荒野拥抱你阅读 215评论 0 0