您的位置:首页 > 运维架构 > Shell

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

2011-10-03 20:55 351 查看
这一部分大家都应该能看懂就不翻译了
Common vi editor command list
For this PurposeUse this vi Command Syntax
To 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 + : + q
To quit without savingesc + : + q!
To save and quit vi editoresc + : + wq
To 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 n
To search for specified word in backward directionesc + ?word (Press 'escape' key, type word-to-find)
To copy the line where cursor is locatedesc + yy
To paste the text just deleted or copied at the cursoresc + p
To delete entire line where cursor is locatedesc + dd
To delete word from cursor positionesc + dw
To 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/cg
To run shell command like ls, cp or date etc within viesc + :!shell-command

For e.g. :!pwd

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: