Common VI Editor command list | VI Editor Commands

ADVERTISEMENT

I Would like to share some commonly used VI editor command which will be useful for the beginners who love to work in VI editor.

This will be more useful for new Linux users.

ADVERTISEMENT
Article will continue after the ad
Purpose vi Command
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 ‘work‘, type as/work)
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/gFor. e.g. :$s/work/workers/gHere word “work” is replace with “workers”
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-commandFor e.g. :!pwd

Original Author:  M.S.Verman

ADVERTISEMENT

POSTS YOU MAY LIKE -:)

Share This Post

Shares