Vi editor commands

Vi editor commands - replace/g For. e.g. :$s/mumbai/pune/g...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Vi
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Common vi editor command list For this Purpose Use this vi Command Syntax To insert new text esc + i ( You have to press 'escape' key then 'i') To save file esc + : + w (Press 'escape' key then 'colon' and finally 'w') To save file with file name (save as) esc + : + w "filename" To quit the vi editor esc + : + q To quit without saving esc + : + q! To save and quit vi editor esc + : + wq To search for specified word in forward direction esc + /word (Press 'escape' key, type /word-to-find, for e.g. to find word ' shri ', type as /shri )
Background image of page 2
Contd. . To continue with search n To search for specified word in backward direction esc + ?word (Press 'escape' key, type word-to-find) To copy the line where cursor is located esc + yy
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
To paste the text just deleted or copied at the cursor esc + p To delete entire line where cursor is located esc + dd To delete word from cursor position esc + dw To Find all occurrence of given word and Replace then globally without confirmation esc + :$s/word-to-find/word-to-
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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 esc + :$s/word-to-find/word-to-replace/cg To run shell command like ls, cp or date etc within vi esc + :!shell-command For e.g. :!pwd How Shell Locates the file To run script, you need to have in the same directory where you created your script, if you are in different directory your script will not run (because of path settings), For e.g. . Your home directory is ( use $ pwd to see current working directory) /home/vivek. Then you created one script called 'first', after creation of this script you moved to some other directory lets say /home/vivek/Letters/Personal if you try to execute your script it will not run To overcome this problem specify complete path of your script $ /bin/sh /home/vivek/first...
View Full Document

Page1 / 7

Vi editor commands - replace/g For. e.g. :$s/mumbai/pune/g...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online