Linux Shell脚本教程(LSST)---基本的vi命令

来源:互联网 发布:网络用语mtf是什么意思 编辑:程序博客网 时间:2024/05/16 14:21

这一部分大家都应该能看懂就不翻译了

Common vi editor command list

For this PurposeUse this vi Command SyntaxTo insert new textesc + i ( You have to press 'escape' key then 'i')To save fileesc + : + w (Press 'escape' key  then 'colon' and finally 'w')To save file with file name (save as)esc + : + w  "filename"To quit the vi editoresc + : + qTo quit without savingesc + : + q!To save and quit vi editoresc + : + wqTo search for specified word in forward directionesc + /word (Press 'escape' key, type /word-to-find, for e.g. to find word 'shri', type as
/shri)To continue with search nTo search for specified word in backward directionesc + ?word (Press 'escape' key, type word-to-find)To copy the line where cursor is locatedesc + yyTo paste the text just deleted or copied at the cursoresc + pTo delete entire line where cursor is locatedesc + ddTo delete word from cursor positionesc + dwTo Find all occurrence of given word and Replace then globally without confirmation esc + :$s/word-to-find/word-to-replace/g

For. e.g. :$s/mumbai/pune/g
Here word "mumbai" is replace with "pune"

 

To Find all occurrence of given word and Replace then globally with confirmationesc + :$s/word-to-find/word-to-replace/cgTo run shell command like ls, cp or date etc within viesc + :!shell-command

For e.g. :!pwd
原创粉丝点击