企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
参考资料: [https://blog.csdn.net/jsut\_rick/article/details/81945771](https://blog.csdn.net/jsut_rick/article/details/81945771) relation between vi and vim, vi is the basics, vim is the advanced vim: it has three modes: ![](https://box.kancloud.cn/caacf9e6ecf94880d183beaee640a9f9_742x465.png) 2.1 【default】Command mode(命令模式), 1. move the cursor 2. copy, cut/delete, past a) copy current line: yy b) paste:p c) copy multiple lines: 3yy d) delete current line: dd e) delete current letter: x f) delete from current position to the end of line: d$ g) delete multiple lines: 2dd h) delete current line, but leave the empty space : D 3. undo(ctrl +z), undo undo (ctrl+y) a) u to undo b) ctrl + r to undo undo 2.2 endofline mode(末行模式) 1. save modification, and to quit 2. search for some content, and replace the content with something else for : a) save changes, :w :w newfilename b) quit, to exit the file, :q c) save and quit, :wq d) to quit without saving changes, :q! e) if you are using root, use :w! to even modify a readonly file for / after the search, to use n to find next match, to use N to find previous match to replace, substitue substitute current line, :s/target/xx (only substitue the firt match) substitute current line, :s/target/xx/g (substitue all matches in current line) substitue multiple lines, :n,ms/target/xx :n,$s/target/xx 2.3 edit mode(编辑模式) 1. modify by typing anything you like i :cursor stays at original position, and letter will be inserted before the cursor. I :cursor goes to the beginning of the line o: cursor goes to next line O:cursor goes to previous line a :cursor goes to next position,and letter will be inserted after the cursor A :cursor goest to the end of the line