vim常用命令收集

来源:互联网 发布:淘宝价格不一样买哪家 编辑:程序博客网 时间:2024/05/23 11:13

在网络上收集了一些常用vim的命令,记下来以备查阅。

基础

:e filenameOpen filename for edition:wSave file:qExit Vim:q!Quit without saving:xWrite file (if changes has been made) and exit:sav filenameSaves file as filename.Repeats the last change made in normal mode5.Repeats 5 times the last change made in normal mode

剪切、复制和粘贴

yCopy the selected text to clipboardpPaste clipboard contentsddCut current lineyyCopy current liney$Copy to end of lineDCut to end of line


1.vim

#在命令行中输入vim,进入vim编辑器

2.

i

#按一下i键,下端显示 --INSERT--
#插入命令,在vim中可能任意字符都有作用
3.
Esc
#退出i(插入)命令进行其它命令使用
4.
:r filename
#读入一个文件内容,并写入到当前编辑器中
5.
:w newfilename
#将该编辑器中的内容写入到一个新文件中
6.
:w
#在编辑的过程中保存文件,相当于word中的ctrl+s
7.
:! command
暂时离开 vi 到指令列模式下执行 command 的显示结果!例如
:!ls
#在编辑过程中执行shell命令ls
8.
:sh
#进入shell命令行,执行完命令后ctrl+d退出重新进入vim编辑继续编辑

在shell命令下,执行ctral+l完成清屏
9.
:wq
#保存文件并退出
10.
ZZ
#保存文件并退出,同上一个命令,注意大写
11.
:q!
#强制退出,不保存
12.
:set number或者:set nu
#使编辑中的文件显示行号
13.
:set nonumber或者:set nonu 
#与上一条命令相反,不显示行号
14.
:help i
#查看插入命令帮助
15.

#撤消上一步操作

/Fedora
#查找Fedora字符
17.
:s /Fedora/Redhat
#将Fedora字符替换为Redhat(只替换在光标所在的行)
18.
dw
#删除单词
dd
#删除行
19.
o
#打开空白一行
20.
vim + filename
#进行文件最后一行进行编辑
21.
vim +n filename

#进入文件第n行进行编辑

附图一张(来源与网络)


0 0