VI Cheat Sheet

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

File: /data/swaraj/Documents/TXT/vikeys

For this Purpose To insert new text To save file finally 'w') To save file with file name (save as) To quit the vi editor To quit without saving To save and quit vi editor To search for specified word in forward direction find, for e.g. to find word 'shri', type as /shri) To continue with search To search for specified word in backward direction find) To copy the line where cursor is located To paste the text just deleted or copied at the cursor To delete entire line where cursor is located To delete word from cursor position

Page 1 of 1
Use this vi Command Syntax esc + i ( You have to press 'escape' key then 'i') esc + : + w (Press 'escape' key then 'colon' and esc esc esc esc esc + + + + + : + w "filename" : + q : + q! : + wq /word (Press 'escape' key, type /word-to-

n esc + ?word (Press 'escape' key, type word-toesc esc esc esc + + + + yy p dd dw esc + :$s/word-to-

To Find all occurrence of given word and Replace then globally without confirmation 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 confirmation find/word-to-replace/cg To run shell command like ls, cp or date etc within vi For e.g. :!pwd esc + :!shell-command

esc + :$s/word-to-

You might also like