Download presentation
Presentation is loading. Please wait.
Published byRolf Dorsey Modified over 9 years ago
1
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:1 Lesson 3: Vi- editor By Simi By Simi
2
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:2 The Vi-Editor Vi commands : vi is a visual display- presentation editor based on an underlying line editor(ex). Characters are normally interpreted as commands (command mode). Some commands allow text to be entered until the key is pressed (insert mode)
3
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:3 The Vi-Editor Vi editor is invoked as # Vi filename : full editing functionality # View filename : file(s) opened read only
4
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:4 The Vi-Editor Three modes of operation (i) Command :for moving around the text ( default as startup) (ii) Insert:for adding text (iii) Execution :extended commands ( compatible with ed)
5
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:5 Vi - Commands to Move the cursor 0start of line $to go to the end of line nGgo to line n Ggo the last line h to move towards the left side jto move toward the down side kto move toward the up side lto move toward the right side
6
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:6 Commands to Move the cursor bto move toward the beginning of word eto move to the end of word. wto move to the start of next word. ^+Fto go forward one screen ^+Bto go backward one screen
7
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:7 Commands to Move the cursor ^+D to move down half screen ^+U to move up half screen <-(backspace)to change character entered Spacebar to move forward Esc to come out of any mode.
8
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:8 Vi – Insert mode Esc + i to enter into insert mode iinsert before character aappend after character Iinsert at the start of line Ainsert at the end of line Oopens new line above the cursor oopens new line below the cursor
9
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:9 Vi – delete mode Esc + d to enter into delete mode x delete character under cursor X delete character to the left of cursor dd deletes complete line dwdeletes to the start of next word d3 deletes next three characters
10
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:10 delete mode d3 deletes previous three characters d 0 deletes to the start of line d1G deletes to the start of file dGdeletes to the end of file Ddeletes to the end of line.
11
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:11 Vi – Change/Replace commands r replace cursor under cursor( type new character under cursor) Rreplaces ( overtype text) until escape( Esc) is pressed. cc change complete line cwchange to the start of next word c3 change next three characters
12
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:12 Change/Replace commands c 0changes to the start of line c1Gchanges to the start of file cGchanges to the end of file c$ changes to the end of line or or Cchanges to the end of line
13
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:13 Vi – Copy and Paste commands Changed text is stored in buffer multiple buffers can be used Text can be copied using the yank(copy) command y yanks( copies) text specifying size of text to copy yyyank complete line ywyank to start of next word y0yank to start of line yGyank to end of file
14
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:14 Copy and Paste commands Text can be pasted back p (lowercase) paste buffer after current position P (uppercase)paste buffer before current position
15
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:15 Vi - Save Commands Vi - Save Commands Esc + Shift : to enter into save mode :q quits vi editor without saving anything :wsaves changes permanently without quitting :q!quits forcefully
16
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:16 Save Commands :w!saves forcefully :wqsaves & come out from vi editor :xsave and quit(exit) Shift+zzsaves & come out from vi editor
17
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:17 Vi – Search and Replace Commands Searches are very powerful /patternsearches forward pattern ?patternsearches backward for pattern Nrepeat last search in opposite direction
18
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:18 Search and Replace Commands Search can be combined with the replace action :1, $s/old/new/g replaces all occurrences of old with new :1, 20s/old/new/gcin the first 20 lines, replace all occurrences of old with new but ask for confirmation of each change. :n, ms/old/new/g replaces all occurrences of old with new between lines n and m.
19
Copyrights© 2008 BVU Amplify DITM Basics of OS,UNIX/LINUX and Shell programming Page:19 Thank You Thank You
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.