SlideShare a Scribd company logo
1 of 11
Changing and Deleting text,
Change word, Change line
under
Vi Editor
UNIX & SHELL PROGRAMMING
 Amity Institute of Information Technology, Jaipur
Objectives
• Changing commands.
• Deleting commands.
• Copy and past commands.
• Advance commands.
2
Change Commands
• The capability to change characters, words, or lines in vi 
without deleting them.
• The relevant commands are:
 
3
Command Description
cc Removes contents of the line, leaving you in insert mode.
cw Changes the word the cursor is on from the cursor to the lowercase w end of the word.
r Replaces the character under the cursor. vi returns to command mode after the replacement is entered.
R
Overwrites multiple characters beginning with the character currently under the cursor. You must use Esc to 
stop the overwriting.
s Replaces the current character with the character you type. Afterward, you are left in insert mode.
S
Deletes the line the cursor is on and replaces with new text. After the new text is entered, vi remains in insert 
mode.
Deleting Commands
• It’s an important commands which can be used to delete
characters and lines in an opened file.
• The relevant commands are:
4
Command Description
x Deletes the character under the cursor location.
X Deletes the character before the cursor location.
dw Deletes from the current cursor location to the next word.
d^ Deletes from current cursor position to the beginning of the line.
d$ Deletes from current cursor position to the end of the line.
D Deletes from the cursor position to the end of the current line.
dd Deletes the line the cursor is on.
NOTE:- As mentioned above, most commands in vi can be prefaced by the number of times you want the action
to occur. For example, 2x deletes two character under the cursor location and 2dd deletes two lines the cursor is
on.
Deleting Commands
5
Copy and Paste Commands
• We can copy lines or words from one place and then We
can past them at another place.
• The relevant commands are:
6
Command Description
yy Copies the current line.
yw Copies the current word from the character the lowercase w cursor is on until the end of the word.
p Puts the copied text after the cursor.
P Puts the yanked text before the cursor.
Advance commands
• There are some advanced commands that simplify day-
to-day editing and allow for more efficient use of vi:
7
Command Description
J Join the current line with the next one. A count joins that many lines.
<<  Shifts the current line to the left by one shift width.
>>  Shifts the current line to the right by one shift width.
~ Switch the case of the character under the cursor.
^G Press CNTRL and G keys at the same time to show the current filename and the status.
U Restore the current line to the state it was in before the cursor entered the line.
u Undo the last change to the file. Typing 'u' again will re-do the change.
Advance commands
J Join the current line with the next one. A count joins that many lines.
:f Displays current position in the file in % and file name, total number of file.
:f filename Renames current file to filename.
:w filename Write to file filename.
:e filename Opens another file with filename.
:cd dirname Changes current working directory to dirname.
:e # Use to toggle between two opened files.
:n In case you open multiple files using vi, use :n to go to next file in the series.
:p
In case you open multiple files using vi, use :p to go to previous file in the
series.
:N
In case you open multiple files using vi, use :N to go to previous file in the
series.
:r file Reads file and inserts it after current line
:nr file Reads file and inserts it after line n.
8
The join Command
9
Undo Commands
10
11

More Related Content

Similar to changing and deleting text ,change word and line under vi editor

Vi editor Linux Editors
Vi editor Linux EditorsVi editor Linux Editors
Vi editor Linux EditorsTONO KURIAKOSE
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editorShay Cohen
 
Using VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit KumarUsing VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit KumarRohit Kumar
 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptxHarsha Patel
 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptxHarsha Patel
 
intro unix/linux 04
intro unix/linux 04intro unix/linux 04
intro unix/linux 04duquoi
 
1_Editors_in_Unix
1_Editors_in_Unix1_Editors_in_Unix
1_Editors_in_UnixGautam Raja
 
VI Editor - R.D.Sivakumar
VI Editor - R.D.SivakumarVI Editor - R.D.Sivakumar
VI Editor - R.D.SivakumarSivakumar R D .
 
VI Editors
VI EditorsVI Editors
VI EditorsDeivanai
 
Vi editor commands
Vi editor commandsVi editor commands
Vi editor commandsFemi Adeyemi
 
Vi reference
Vi referenceVi reference
Vi referenceaireddy
 
Beginning with vi text editor
Beginning with vi text editorBeginning with vi text editor
Beginning with vi text editorJose Pla
 
Escape Sequences and Variables
Escape Sequences and VariablesEscape Sequences and Variables
Escape Sequences and Variablesyarkhosh
 
101 3.8.2 vim reference card
101 3.8.2 vim reference card101 3.8.2 vim reference card
101 3.8.2 vim reference cardAcácio Oliveira
 

Similar to changing and deleting text ,change word and line under vi editor (20)

Vi editor
Vi   editorVi   editor
Vi editor
 
Vi editor Linux Editors
Vi editor Linux EditorsVi editor Linux Editors
Vi editor Linux Editors
 
Vi editor
Vi editorVi editor
Vi editor
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editor
 
Using vi editor
Using vi editorUsing vi editor
Using vi editor
 
Using VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit KumarUsing VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit Kumar
 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptx
 
Using Vi Editor.pptx
Using Vi Editor.pptxUsing Vi Editor.pptx
Using Vi Editor.pptx
 
intro unix/linux 04
intro unix/linux 04intro unix/linux 04
intro unix/linux 04
 
1_Editors_in_Unix
1_Editors_in_Unix1_Editors_in_Unix
1_Editors_in_Unix
 
VI Editor - R.D.Sivakumar
VI Editor - R.D.SivakumarVI Editor - R.D.Sivakumar
VI Editor - R.D.Sivakumar
 
VI Editors
VI EditorsVI Editors
VI Editors
 
vim-cheatsheet.pdf
vim-cheatsheet.pdfvim-cheatsheet.pdf
vim-cheatsheet.pdf
 
Vi editor commands
Vi editor commandsVi editor commands
Vi editor commands
 
Vim
VimVim
Vim
 
Vi reference
Vi referenceVi reference
Vi reference
 
Vi reference
Vi referenceVi reference
Vi reference
 
Beginning with vi text editor
Beginning with vi text editorBeginning with vi text editor
Beginning with vi text editor
 
Escape Sequences and Variables
Escape Sequences and VariablesEscape Sequences and Variables
Escape Sequences and Variables
 
101 3.8.2 vim reference card
101 3.8.2 vim reference card101 3.8.2 vim reference card
101 3.8.2 vim reference card
 

More from Shourya Puri

Smo(social media optimisation)
Smo(social media optimisation)Smo(social media optimisation)
Smo(social media optimisation)Shourya Puri
 
SMO (social media optimization)
SMO (social media optimization)SMO (social media optimization)
SMO (social media optimization)Shourya Puri
 
Seo digital marketing
Seo digital marketingSeo digital marketing
Seo digital marketingShourya Puri
 
report of dance, drama and music academy and auditorium
report of dance, drama and music academy and auditoriumreport of dance, drama and music academy and auditorium
report of dance, drama and music academy and auditoriumShourya Puri
 
Synopsis Of cultural complex
Synopsis Of cultural complexSynopsis Of cultural complex
Synopsis Of cultural complexShourya Puri
 
Wildcraft marketing
Wildcraft marketingWildcraft marketing
Wildcraft marketingShourya Puri
 
Tender calling procedure
Tender calling procedureTender calling procedure
Tender calling procedureShourya Puri
 
History of jammu & kashmir
History  of jammu & kashmirHistory  of jammu & kashmir
History of jammu & kashmirShourya Puri
 
Town plan auroville
Town plan aurovilleTown plan auroville
Town plan aurovilleShourya Puri
 
Xeriscaping landscape and bioswale
Xeriscaping  landscape and bioswaleXeriscaping  landscape and bioswale
Xeriscaping landscape and bioswaleShourya Puri
 
MODERN CONSTRUCTION METHODS
MODERN CONSTRUCTION METHODSMODERN CONSTRUCTION METHODS
MODERN CONSTRUCTION METHODSShourya Puri
 
Sustainable Waste Management
Sustainable Waste ManagementSustainable Waste Management
Sustainable Waste ManagementShourya Puri
 
Improve communication skills
Improve communication skillsImprove communication skills
Improve communication skillsShourya Puri
 
SITE VISIT ARCHITECTRE
SITE VISIT ARCHITECTRE  SITE VISIT ARCHITECTRE
SITE VISIT ARCHITECTRE Shourya Puri
 
Convention hall interior acoustics
Convention hall  interior acoustics Convention hall  interior acoustics
Convention hall interior acoustics Shourya Puri
 

More from Shourya Puri (20)

Smo(social media optimisation)
Smo(social media optimisation)Smo(social media optimisation)
Smo(social media optimisation)
 
SMO (social media optimization)
SMO (social media optimization)SMO (social media optimization)
SMO (social media optimization)
 
Seo digital marketing
Seo digital marketingSeo digital marketing
Seo digital marketing
 
report of dance, drama and music academy and auditorium
report of dance, drama and music academy and auditoriumreport of dance, drama and music academy and auditorium
report of dance, drama and music academy and auditorium
 
Synopsis Of cultural complex
Synopsis Of cultural complexSynopsis Of cultural complex
Synopsis Of cultural complex
 
Wildcraft marketing
Wildcraft marketingWildcraft marketing
Wildcraft marketing
 
Wagah border
Wagah border Wagah border
Wagah border
 
Tender calling procedure
Tender calling procedureTender calling procedure
Tender calling procedure
 
History of jammu & kashmir
History  of jammu & kashmirHistory  of jammu & kashmir
History of jammu & kashmir
 
Town plan auroville
Town plan aurovilleTown plan auroville
Town plan auroville
 
Hybrid trusses
Hybrid trussesHybrid trusses
Hybrid trusses
 
Xeriscaping landscape and bioswale
Xeriscaping  landscape and bioswaleXeriscaping  landscape and bioswale
Xeriscaping landscape and bioswale
 
Glass Report
Glass ReportGlass Report
Glass Report
 
Fiberglass
FiberglassFiberglass
Fiberglass
 
MODERN CONSTRUCTION METHODS
MODERN CONSTRUCTION METHODSMODERN CONSTRUCTION METHODS
MODERN CONSTRUCTION METHODS
 
Sustainable Waste Management
Sustainable Waste ManagementSustainable Waste Management
Sustainable Waste Management
 
Improve communication skills
Improve communication skillsImprove communication skills
Improve communication skills
 
Office case study
Office case studyOffice case study
Office case study
 
SITE VISIT ARCHITECTRE
SITE VISIT ARCHITECTRE  SITE VISIT ARCHITECTRE
SITE VISIT ARCHITECTRE
 
Convention hall interior acoustics
Convention hall  interior acoustics Convention hall  interior acoustics
Convention hall interior acoustics
 

Recently uploaded

How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 

Recently uploaded (20)

How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

changing and deleting text ,change word and line under vi editor

  • 1. Changing and Deleting text, Change word, Change line under Vi Editor UNIX & SHELL PROGRAMMING  Amity Institute of Information Technology, Jaipur
  • 2. Objectives • Changing commands. • Deleting commands. • Copy and past commands. • Advance commands. 2
  • 3. Change Commands • The capability to change characters, words, or lines in vi  without deleting them. • The relevant commands are:   3 Command Description cc Removes contents of the line, leaving you in insert mode. cw Changes the word the cursor is on from the cursor to the lowercase w end of the word. r Replaces the character under the cursor. vi returns to command mode after the replacement is entered. R Overwrites multiple characters beginning with the character currently under the cursor. You must use Esc to  stop the overwriting. s Replaces the current character with the character you type. Afterward, you are left in insert mode. S Deletes the line the cursor is on and replaces with new text. After the new text is entered, vi remains in insert  mode.
  • 4. Deleting Commands • It’s an important commands which can be used to delete characters and lines in an opened file. • The relevant commands are: 4 Command Description x Deletes the character under the cursor location. X Deletes the character before the cursor location. dw Deletes from the current cursor location to the next word. d^ Deletes from current cursor position to the beginning of the line. d$ Deletes from current cursor position to the end of the line. D Deletes from the cursor position to the end of the current line. dd Deletes the line the cursor is on. NOTE:- As mentioned above, most commands in vi can be prefaced by the number of times you want the action to occur. For example, 2x deletes two character under the cursor location and 2dd deletes two lines the cursor is on.
  • 6. Copy and Paste Commands • We can copy lines or words from one place and then We can past them at another place. • The relevant commands are: 6 Command Description yy Copies the current line. yw Copies the current word from the character the lowercase w cursor is on until the end of the word. p Puts the copied text after the cursor. P Puts the yanked text before the cursor.
  • 7. Advance commands • There are some advanced commands that simplify day- to-day editing and allow for more efficient use of vi: 7 Command Description J Join the current line with the next one. A count joins that many lines. <<  Shifts the current line to the left by one shift width. >>  Shifts the current line to the right by one shift width. ~ Switch the case of the character under the cursor. ^G Press CNTRL and G keys at the same time to show the current filename and the status. U Restore the current line to the state it was in before the cursor entered the line. u Undo the last change to the file. Typing 'u' again will re-do the change.
  • 8. Advance commands J Join the current line with the next one. A count joins that many lines. :f Displays current position in the file in % and file name, total number of file. :f filename Renames current file to filename. :w filename Write to file filename. :e filename Opens another file with filename. :cd dirname Changes current working directory to dirname. :e # Use to toggle between two opened files. :n In case you open multiple files using vi, use :n to go to next file in the series. :p In case you open multiple files using vi, use :p to go to previous file in the series. :N In case you open multiple files using vi, use :N to go to previous file in the series. :r file Reads file and inserts it after current line :nr file Reads file and inserts it after line n. 8
  • 11. 11