SlideShare a Scribd company logo
1 of 8
Using vi
2 Modes
Command Mode
vi starts in command mode. In command mode, everything you
type is a command to do something, like:
• move the cursor around
• save, quit, open a new file
• find and replace
• copy and paste, etc.
Insert Mode
While in insert mode, everything you type is inserted into the
document you’re editing.
Command Mode Insert Mode
i - ...at the current cursor position
I - ...at the beginning of the current line
a - ...at the next character
A - ...at the end of the current line
o - ...below the current line
O - ...above the current line
... plus lots more ways to get into insert mode
Esc
Ctrl-[
Ctrl-c
Get into insert mode:
Get into command mode:
You switch between
these two modes a lot
as you’re editing
Editing in command mode
• h j k l – Move cursor left, down, up, right
• x – Delete a character
• 5x – Delete 5 characters
• dd – Delete a line
• 5dd – Delete 5 lines
• dj – Delete the line below the cursor
• dk – Delete the line above the cursor
• u - Undo
Copy and Paste
Every time you delete something in vi, it gets
stored in a buffer that can then be pasted into
the file with p or P.
To put something into the copy buffer without
deleting it, you “yank” it using a variation of the
y command.
• yy – Yank the current line into the copy
buffer
Search and Replace
• /search_string<Enter> - Search for
“search_string” in the document. Type n to
jump to the next search result if there’s more
than 1
• :%s/aaa/a/g<Enter> - Replace all
occurrences of “aaa” with “a”.
Search and replace commands use a regex
language that supports wildcards, etc.
Saving, quitting, and opening files
• :w, :wq, :q, :q! – Save, save-quit, quit.
Add a ! to any of these commands to force-
save or force-quit.
• :e file.js – Start editing a new file
• :sp file.js, :vsp file.js – Open a
new file in a split window, horizontally or
vertically. To move between windows, type
Ctrl-w then a direction key (h,j,k,l).

More Related Content

Viewers also liked

תהליך הרכישה באתר www.mehunan.com
 תהליך הרכישה באתר www.mehunan.com תהליך הרכישה באתר www.mehunan.com
תהליך הרכישה באתר www.mehunan.comMehunan Com
 
Биометрическая система идентификации
Биометрическая система идентификацииБиометрическая система идентификации
Биометрическая система идентификацииДмитрий Пасков
 
getEUjob.com
getEUjob.comgetEUjob.com
getEUjob.compakozdi
 
תלמידים מחוננים
תלמידים מחונניםתלמידים מחוננים
תלמידים מחונניםMehunan Com
 
Carta de recomendación
Carta de recomendaciónCarta de recomendación
Carta de recomendaciónRaul Hervert
 

Viewers also liked (13)

The "vi" Text Editor
The "vi" Text EditorThe "vi" Text Editor
The "vi" Text Editor
 
Unix Administration 1
Unix Administration 1Unix Administration 1
Unix Administration 1
 
תהליך הרכישה באתר www.mehunan.com
 תהליך הרכישה באתר www.mehunan.com תהליך הרכישה באתר www.mehunan.com
תהליך הרכישה באתר www.mehunan.com
 
Vi editor
Vi   editorVi   editor
Vi editor
 
Ingles
InglesIngles
Ingles
 
Ingles
InglesIngles
Ingles
 
Ingles
InglesIngles
Ingles
 
Биометрическая система идентификации
Биометрическая система идентификацииБиометрическая система идентификации
Биометрическая система идентификации
 
getEUjob.com
getEUjob.comgetEUjob.com
getEUjob.com
 
תלמידים מחוננים
תלמידים מחונניםתלמידים מחוננים
תלמידים מחוננים
 
áLbum de fotografías
áLbum de fotografíasáLbum de fotografías
áLbum de fotografías
 
Carta de recomendación
Carta de recomendaciónCarta de recomendación
Carta de recomendación
 
Exe11
Exe11Exe11
Exe11
 

Similar to Essential vi Commands for Editing and Navigation

07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editorShay Cohen
 
Vi editor Linux Editors
Vi editor Linux EditorsVi editor Linux Editors
Vi editor Linux EditorsTONO KURIAKOSE
 
Presentacion vim
Presentacion vimPresentacion vim
Presentacion vimIcalia Labs
 
Linux text editors Vim nano
Linux text editors Vim nano Linux text editors Vim nano
Linux text editors Vim nano Md Meherab Hossen
 
lectuer 21-22.pptx
lectuer 21-22.pptxlectuer 21-22.pptx
lectuer 21-22.pptxpoonam256394
 
Mission vim possible-full
Mission vim possible-fullMission vim possible-full
Mission vim possible-fullSam Gottfried
 
Unix shell talk - RIT SSE
Unix shell talk - RIT SSEUnix shell talk - RIT SSE
Unix shell talk - RIT SSEMatt Mokary
 
Linux Basic commands and VI Editor
Linux Basic commands and VI EditorLinux Basic commands and VI Editor
Linux Basic commands and VI Editorshanmuga rajan
 
015-Editing-Files-With-Vi.pdf
015-Editing-Files-With-Vi.pdf015-Editing-Files-With-Vi.pdf
015-Editing-Files-With-Vi.pdfssuser584832
 
1_Editors_in_Unix
1_Editors_in_Unix1_Editors_in_Unix
1_Editors_in_UnixGautam Raja
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppthazhamina
 
Introduction to vi editor
Introduction to vi editorIntroduction to vi editor
Introduction to vi editorU.P Police
 
St. Louis Days of .NET 2013: Visual Studio Tips and Tricks
St. Louis Days of .NET 2013: Visual Studio Tips and TricksSt. Louis Days of .NET 2013: Visual Studio Tips and Tricks
St. Louis Days of .NET 2013: Visual Studio Tips and TricksKevin Grossnicklaus
 

Similar to Essential vi Commands for Editing and Navigation (20)

Vi Editor
Vi EditorVi Editor
Vi Editor
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editor
 
Vi editor Linux Editors
Vi editor Linux EditorsVi editor Linux Editors
Vi editor Linux Editors
 
Vim
VimVim
Vim
 
Presentacion vim
Presentacion vimPresentacion vim
Presentacion vim
 
Vim Cheat Sheet.pdf
Vim Cheat Sheet.pdfVim Cheat Sheet.pdf
Vim Cheat Sheet.pdf
 
Linux text editors Vim nano
Linux text editors Vim nano Linux text editors Vim nano
Linux text editors Vim nano
 
Vim Basics
Vim BasicsVim Basics
Vim Basics
 
Vi editor
Vi editorVi editor
Vi editor
 
lectuer 21-22.pptx
lectuer 21-22.pptxlectuer 21-22.pptx
lectuer 21-22.pptx
 
Mission vim possible-full
Mission vim possible-fullMission vim possible-full
Mission vim possible-full
 
Unix shell talk - RIT SSE
Unix shell talk - RIT SSEUnix shell talk - RIT SSE
Unix shell talk - RIT SSE
 
Linux Basic commands and VI Editor
Linux Basic commands and VI EditorLinux Basic commands and VI Editor
Linux Basic commands and VI Editor
 
015-Editing-Files-With-Vi.pdf
015-Editing-Files-With-Vi.pdf015-Editing-Files-With-Vi.pdf
015-Editing-Files-With-Vi.pdf
 
1_Editors_in_Unix
1_Editors_in_Unix1_Editors_in_Unix
1_Editors_in_Unix
 
Linux basic1&amp;2
Linux basic1&amp;2Linux basic1&amp;2
Linux basic1&amp;2
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
Introduction to vi editor
Introduction to vi editorIntroduction to vi editor
Introduction to vi editor
 
St. Louis Days of .NET 2013: Visual Studio Tips and Tricks
St. Louis Days of .NET 2013: Visual Studio Tips and TricksSt. Louis Days of .NET 2013: Visual Studio Tips and Tricks
St. Louis Days of .NET 2013: Visual Studio Tips and Tricks
 
Linex
LinexLinex
Linex
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Essential vi Commands for Editing and Navigation

  • 2. 2 Modes Command Mode vi starts in command mode. In command mode, everything you type is a command to do something, like: • move the cursor around • save, quit, open a new file • find and replace • copy and paste, etc. Insert Mode While in insert mode, everything you type is inserted into the document you’re editing.
  • 3. Command Mode Insert Mode i - ...at the current cursor position I - ...at the beginning of the current line a - ...at the next character A - ...at the end of the current line o - ...below the current line O - ...above the current line ... plus lots more ways to get into insert mode Esc Ctrl-[ Ctrl-c Get into insert mode: Get into command mode: You switch between these two modes a lot as you’re editing
  • 4. Editing in command mode • h j k l – Move cursor left, down, up, right • x – Delete a character • 5x – Delete 5 characters • dd – Delete a line • 5dd – Delete 5 lines • dj – Delete the line below the cursor • dk – Delete the line above the cursor • u - Undo
  • 5. Copy and Paste Every time you delete something in vi, it gets stored in a buffer that can then be pasted into the file with p or P. To put something into the copy buffer without deleting it, you “yank” it using a variation of the y command. • yy – Yank the current line into the copy buffer
  • 6. Search and Replace • /search_string<Enter> - Search for “search_string” in the document. Type n to jump to the next search result if there’s more than 1 • :%s/aaa/a/g<Enter> - Replace all occurrences of “aaa” with “a”. Search and replace commands use a regex language that supports wildcards, etc.
  • 7.
  • 8. Saving, quitting, and opening files • :w, :wq, :q, :q! – Save, save-quit, quit. Add a ! to any of these commands to force- save or force-quit. • :e file.js – Start editing a new file • :sp file.js, :vsp file.js – Open a new file in a split window, horizontally or vertically. To move between windows, type Ctrl-w then a direction key (h,j,k,l).