最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

★★★Common vi editor command list

工作和技术 crifan 1597浏览 0评论

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 searchn
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 confirmationesc + :$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

Note:

the "esc + :$s/word-to-find/word-to-replace/g " in above, the "s" is the abbrevaion of substitute

and more details about how to find and replace text, pls refer ★★★★★【转】vim文本编辑器中查找并替换功能详解 http://www.vim.org/htmldoc/usr_10.html

转载请注明:在路上 » ★★★Common vi editor command list

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
79 queries in 0.163 seconds, using 22.09MB memory