vi editor Manual

The role of the vi editor

  • Linux system configuration files stored in each directory majority in the form of text files
  • Linux system administrators manage the system by modifying the configuration file

Category text editor

  • Line editor and full-screen editor
  • Character interface and GUI editor editor
  • Commonly used characters Interface Editor

Directly into the editing environment

# vi

Into the editing environment and open the (new) environment

# vi newfile

Quit vi editing environment

# :q!                       //输入末行命令放弃对文件的修改,并退出编辑器
# :q!                       //编辑文本后,输入末行命令保存对文件的修改,并退出编辑器

insert

i                           //当前行插入
o                           //下一行插入,光标在行首

delete

x                           //删除当前光标字符
dd                          //删除整行/剪切

copy

yy                          //复制当前一行

Stick

p                           //粘贴

Undo

u                           //撤销当前一行    

Next page

ctrl + f                    //下翻页
Ctrl + b                    //上翻页

Find, locate and replace

/word                       //从上而下在文件中查找字符串“Word”
?word                       //从下而上在文件中查找字符串“Word”
n                           //定位下一个匹配的被查找字符串
N                           //定位上一个匹配的被查找字符串
:%s/old/new/g               //在整个文件范围内替换所有的字符串

Guess you like

Origin www.cnblogs.com/ghbuff/p/12395574.html