1、启动文本编辑器
vi abc.txt
2、常用命令
//命令输入方法 先输入“: ”,然后输入相应命令
2.1 从命令模式切换到输入模式
a/i //change mode from comand to edit
2.2 从输入模式切换到命令模式
ESC(key board) // back to comand mode
2.3 退出和强制退出
q // quit no save
q! // force quit no save
2.4 退出保存和强制退出并保存
wq //save and quit
wq! // save and force quit
2.5 单词搜索
/WordOfSearch // WordOfSearch is the word you will search , key Board N key search next
2.6 Jump to particular line that contains main() function from a shell prompt(直接跳到main函数那一行)
vi +/main initlib.c
2.7 Jump to particular line number from a shell prompt, enter:(直接跳到指定行)
vi +linenumber file.c
2.8 To display line numbers along the left side of a window, type any one of the following command while using text editor:(显示行号)
set nu
2.9 To turn off line number again enter the same command:(关闭显示行号)
set nu!
2.10 If you need number every time you start vi/vim, append following line to your ~/.vimrc file:(永久显示行号)
Append the following line:(在~/.vimrc文件后加上下面的命令,然后保存退出)
set nu
Save and close the file.