SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Vi editor
What is vi
The vi editor is elaborated as visual editor. It is installed in every Unix system. It is a very
powerful application. An improved version of vi editor is vim but most Linux systems have vi
editor installed.
vi editor has two modes:
Command Mode: In command mode, actions are taken on the file. The vi editor starts in
command mode. Typed words will act as commands in vi editor. To pass a command you
have to be in command mode.
Insert Mode: In insert mode, entered text will be inserted into the file. Esc key will take you
to the command mode from insert mode.
 By default, vi editor starts in command mode. To enter text, you
have to be in insert mode, just type 'i' and you'll be in insert
mode. Although, after typing i nothing will appear on the screen
but you'll be in insert mode. Now you can type anything.
 To exit from insert mode press Esc key, you'll be directed to
command mode.
 Using vi
 The vi editor tool is an interactive tool as it displays changes
made in the file on the screen while you edit the file.
 In vi editor you can insert, edit or remove a word as cursor
moves throughout the file.
 Commands are specified for each function like to delete it's x or
dd.
 The vi editor is case-sensitive. For example, p allows you to
paste after the current line while P allows you to paste before the
current line.
 vi syntax:
 vi <fileName>
 Linux vi example
 Let's understand vi through an
example:
 To start vi open your terminal and type
vi command followed by file name. If
your file is in some other directory, you
can specify the file path. And if in
case, your file doesn't exist, it will
create a new file with the specified
name at the given location.
To save and quit
 You can save and quit vi editor from command mode. Before writing save or
quit command you have to press colon (:). Colon allows you to give
instructions to vi.
 exit vi table:
 Commands Action
 :wq Save and quit
 :w Save
 :q Quit
 :w fname Save as fname
 ZZ Save and quit
 :q! Quit discarding changes made
 :w! Save (and write to non-writable file)
 To exit from vi, first ensure that you are in command mode. Now, type :wq
and press enter. It will save and quit vi.
 Type :wq to save and exit the file.
 Vi Commands
 Linux vi editor is different from other editors. You have to use different keys to use different
functions. Although, it's quite easy and interesting to use vi editor.
 The vi editor commands are case sensitive.
 Have a look at the vi commands in the following table.
 To switch from command to insert mode:
 Command Action
 i Start typing before the current character
 I Start typing at the start of current line
 a Start typing after the current character
 A Start typing at the end of current line
 o Start typing on a new line after the current line
 O Start typing on a new line before the current line
To move around a file:
 Commands Action
 j To move down
 k To move up
 h To move left
 l To move right
 To jump lines:
 Commands Action
 G Will direct you at the last line of the file
 `` Will direct you to your last position in the
file
To delete:
 Commands Action
 x Delete the current character
 X Delete the character before the cursor
 r Replace the current character
 xp Switch two characters
 dd Delete the current line
 D Delete the current line from current character to the end
of the line
 dG delete from the current line to the end of the file
 To repeat and undo:
 Commands Action
 u Undo the last command
 . Repeat the last command
Command to cut, copy and
paste:
 Commands Action
 dd Delete a line
 yy (yank yank) copy a line
 p Paste after the current line
 P Paste before the current line
 Command to cut, copy and paste in blocks:
 Commands Action
 <n>dd Delete the specified n number of
lines
 <n>yy Copy the specified n number of
lines
 Start and end of line:
 CommandsAction
 θ Bring at the start of the current line
 ^ Bring at the start of the current line
 $ Bring at the end of the current line
 dθ Delete till start of a line
 d$ Delete till end of a line
 Joining lines:
 CommandsAction
 J Join two lines
 yyp Repeat the current line
 ddp Swap two lines
 Move forward or backward:
 Commands Action
 w Move one word forward
 b Move one word backward
 <n>w Move specified number of words forward
 dw Delete one word
 yw Copy one word
 <n>dw Delete specified number of words
 Search a string:
 Commands Action
 /string Forward search for given string
 ?string Backward search for given string
 /^string Forward search string at beginning of a line
 /string$ Forward search string at end of a line
 n Go to next occurrence of searched string
 /<he> Search for the word he (and not for there, here,
etc.)
 /pl[abc]ce Search for place, plbce, and plcce
 vi switch from command mode
 To start typing in vi editor, you have to be in insert
mode. There are different commands in vi editor
through which you can start typing at different locations
in insert mode. They are defined below.
 i
 The i command allows us to write before the current
character.
 vi move around a file
 In command mode, we can move to different parts of a
file with h,j,k,l commands. These (h,j,k,l) keys are used
because at the time of vi invention, arrow keys were not
invented. Although, we can use arrow keys also. Arrow
keys and h,j,k,l keys work same.
 j

More Related Content

PPT
Vi editor in linux
ODP
Introduction to Shell script
PPTX
Zero Trust and Data Security
PDF
Operating System fo IoT
PPTX
DDoS ATTACKS
PDF
HTML CSS Basics
PPTX
AI Algorithms
PPT
Effective Communication Skills
Vi editor in linux
Introduction to Shell script
Zero Trust and Data Security
Operating System fo IoT
DDoS ATTACKS
HTML CSS Basics
AI Algorithms
Effective Communication Skills

What's hot (20)

PPTX
PPTX
Vi editor
PPTX
VI editor in unix
PPT
Shell programming
PPTX
PPTX
Unix ppt
PPTX
Object Oriented Programming
PPTX
Data types
PPTX
Linux commands
PPTX
Linux operating system - Overview
PPTX
Vim Editor And Basic Scripting (Ch-7)
PPTX
Inheritance in c++
PPTX
Unix Operating System
PPTX
Bash shell scripting
PPTX
Android activity lifecycle
PPT
Linux basic commands
PDF
Intro to Linux Shell Scripting
PPTX
SQL Commands
PPTX
Introduction to linux
PPTX
Array Introduction One-dimensional array Multidimensional array
Vi editor
VI editor in unix
Shell programming
Unix ppt
Object Oriented Programming
Data types
Linux commands
Linux operating system - Overview
Vim Editor And Basic Scripting (Ch-7)
Inheritance in c++
Unix Operating System
Bash shell scripting
Android activity lifecycle
Linux basic commands
Intro to Linux Shell Scripting
SQL Commands
Introduction to linux
Array Introduction One-dimensional array Multidimensional array
Ad

Viewers also liked (20)

PDF
PPT
Linux command ppt
PPT
1359 Vi Editor
PDF
Using VI Editor in Red Hat by Rohit Kumar
PPT
Introduction to vi editor
PPTX
Linux files
PDF
DOCX
The linux file system structure
PDF
Linux Network commands
PDF
Linux Directory Structure
PPT
Linux ppt
PPT
Linux Troubleshooting
PPTX
File permission in linux
ODP
Linux commands
PDF
tybsc it sem 5 Linux administration notes of unit 1,2,3,4,5,6 version 3
PPT
Basic command ppt
ODP
Linux Introduction (Commands)
ODP
An Introduction to Linux
PDF
Linux Systems Performance 2016
PDF
Introduction to Linux
Linux command ppt
1359 Vi Editor
Using VI Editor in Red Hat by Rohit Kumar
Introduction to vi editor
Linux files
The linux file system structure
Linux Network commands
Linux Directory Structure
Linux ppt
Linux Troubleshooting
File permission in linux
Linux commands
tybsc it sem 5 Linux administration notes of unit 1,2,3,4,5,6 version 3
Basic command ppt
Linux Introduction (Commands)
An Introduction to Linux
Linux Systems Performance 2016
Introduction to Linux
Ad

Similar to Vi editor (20)

PPTX
Vi Vi Editor Unit 4 Power point presentation
PDF
1_Editors_in_Unix
PDF
015-Editing-Files-With-Vi.pdf
PDF
Using vi editor
PDF
Vi editor commands
PDF
Vi editor Linux Editors
PPT
Mastering the Linux vi Editor: Essential Commands and Techniques
PPTX
Using Vi Editor.pptx
PPTX
Using Vi Editor.pptx
PPTX
lectuer 21-22.pptx
PPT
07 vi text_editor
PDF
Tuffarsi in vim
PPTX
Linux Text Editor (Vi) Command List Summary
PPT
VI Editors
DOC
Qc document draft
PPTX
Text editor In RHEL
PDF
Vi reference
PDF
Vi reference
ODP
PPT
intro unix/linux 04
Vi Vi Editor Unit 4 Power point presentation
1_Editors_in_Unix
015-Editing-Files-With-Vi.pdf
Using vi editor
Vi editor commands
Vi editor Linux Editors
Mastering the Linux vi Editor: Essential Commands and Techniques
Using Vi Editor.pptx
Using Vi Editor.pptx
lectuer 21-22.pptx
07 vi text_editor
Tuffarsi in vim
Linux Text Editor (Vi) Command List Summary
VI Editors
Qc document draft
Text editor In RHEL
Vi reference
Vi reference
intro unix/linux 04

More from Ramakrishna kapa (20)

PPTX
Load balancer in mule
PPTX
Anypoint connectors
PPTX
Batch processing
PPTX
Msmq connectivity
PPTX
Scopes in mule
PPTX
Data weave more operations
PPTX
Basic math operations using dataweave
PPTX
Dataweave types operators
PPTX
Operators in mule dataweave
PPTX
Data weave in mule
PPTX
Servicenow connector
PPTX
Introduction to testing mule
PPTX
Choice flow control
PPTX
Message enricher example
PPTX
Mule exception strategies
PPTX
Anypoint connector basics
PPTX
Mule global elements
PPTX
Mule message structure and varibles scopes
PPTX
How to create an api in mule
PPTX
Log4j is a reliable, fast and flexible
Load balancer in mule
Anypoint connectors
Batch processing
Msmq connectivity
Scopes in mule
Data weave more operations
Basic math operations using dataweave
Dataweave types operators
Operators in mule dataweave
Data weave in mule
Servicenow connector
Introduction to testing mule
Choice flow control
Message enricher example
Mule exception strategies
Anypoint connector basics
Mule global elements
Mule message structure and varibles scopes
How to create an api in mule
Log4j is a reliable, fast and flexible

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation theory and applications.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
KodekX | Application Modernization Development
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Modernizing your data center with Dell and AMD
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Building Integrated photovoltaic BIPV_UPV.pdf
A Presentation on Artificial Intelligence
Encapsulation theory and applications.pdf
Big Data Technologies - Introduction.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
KodekX | Application Modernization Development
“AI and Expert System Decision Support & Business Intelligence Systems”
The Rise and Fall of 3GPP – Time for a Sabbatical?
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Encapsulation_ Review paper, used for researhc scholars
Per capita expenditure prediction using model stacking based on satellite ima...
Modernizing your data center with Dell and AMD
Review of recent advances in non-invasive hemoglobin estimation
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Machine learning based COVID-19 study performance prediction
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
CIFDAQ's Market Insight: SEC Turns Pro Crypto

Vi editor

  • 1. Vi editor What is vi The vi editor is elaborated as visual editor. It is installed in every Unix system. It is a very powerful application. An improved version of vi editor is vim but most Linux systems have vi editor installed. vi editor has two modes: Command Mode: In command mode, actions are taken on the file. The vi editor starts in command mode. Typed words will act as commands in vi editor. To pass a command you have to be in command mode. Insert Mode: In insert mode, entered text will be inserted into the file. Esc key will take you to the command mode from insert mode.
  • 2.  By default, vi editor starts in command mode. To enter text, you have to be in insert mode, just type 'i' and you'll be in insert mode. Although, after typing i nothing will appear on the screen but you'll be in insert mode. Now you can type anything.  To exit from insert mode press Esc key, you'll be directed to command mode.  Using vi  The vi editor tool is an interactive tool as it displays changes made in the file on the screen while you edit the file.  In vi editor you can insert, edit or remove a word as cursor moves throughout the file.  Commands are specified for each function like to delete it's x or dd.  The vi editor is case-sensitive. For example, p allows you to paste after the current line while P allows you to paste before the current line.  vi syntax:  vi <fileName>
  • 3.  Linux vi example  Let's understand vi through an example:  To start vi open your terminal and type vi command followed by file name. If your file is in some other directory, you can specify the file path. And if in case, your file doesn't exist, it will create a new file with the specified name at the given location.
  • 4. To save and quit  You can save and quit vi editor from command mode. Before writing save or quit command you have to press colon (:). Colon allows you to give instructions to vi.  exit vi table:  Commands Action  :wq Save and quit  :w Save  :q Quit  :w fname Save as fname  ZZ Save and quit  :q! Quit discarding changes made  :w! Save (and write to non-writable file)  To exit from vi, first ensure that you are in command mode. Now, type :wq and press enter. It will save and quit vi.  Type :wq to save and exit the file.
  • 5.  Vi Commands  Linux vi editor is different from other editors. You have to use different keys to use different functions. Although, it's quite easy and interesting to use vi editor.  The vi editor commands are case sensitive.  Have a look at the vi commands in the following table.  To switch from command to insert mode:  Command Action  i Start typing before the current character  I Start typing at the start of current line  a Start typing after the current character  A Start typing at the end of current line  o Start typing on a new line after the current line  O Start typing on a new line before the current line
  • 6. To move around a file:  Commands Action  j To move down  k To move up  h To move left  l To move right  To jump lines:  Commands Action  G Will direct you at the last line of the file  `` Will direct you to your last position in the file
  • 7. To delete:  Commands Action  x Delete the current character  X Delete the character before the cursor  r Replace the current character  xp Switch two characters  dd Delete the current line  D Delete the current line from current character to the end of the line  dG delete from the current line to the end of the file  To repeat and undo:  Commands Action  u Undo the last command  . Repeat the last command
  • 8. Command to cut, copy and paste:  Commands Action  dd Delete a line  yy (yank yank) copy a line  p Paste after the current line  P Paste before the current line  Command to cut, copy and paste in blocks:  Commands Action  <n>dd Delete the specified n number of lines  <n>yy Copy the specified n number of lines
  • 9.  Start and end of line:  CommandsAction  θ Bring at the start of the current line  ^ Bring at the start of the current line  $ Bring at the end of the current line  dθ Delete till start of a line  d$ Delete till end of a line  Joining lines:  CommandsAction  J Join two lines  yyp Repeat the current line  ddp Swap two lines
  • 10.  Move forward or backward:  Commands Action  w Move one word forward  b Move one word backward  <n>w Move specified number of words forward  dw Delete one word  yw Copy one word  <n>dw Delete specified number of words  Search a string:  Commands Action  /string Forward search for given string  ?string Backward search for given string  /^string Forward search string at beginning of a line  /string$ Forward search string at end of a line  n Go to next occurrence of searched string  /<he> Search for the word he (and not for there, here, etc.)  /pl[abc]ce Search for place, plbce, and plcce
  • 11.  vi switch from command mode  To start typing in vi editor, you have to be in insert mode. There are different commands in vi editor through which you can start typing at different locations in insert mode. They are defined below.  i  The i command allows us to write before the current character.  vi move around a file  In command mode, we can move to different parts of a file with h,j,k,l commands. These (h,j,k,l) keys are used because at the time of vi invention, arrow keys were not invented. Although, we can use arrow keys also. Arrow keys and h,j,k,l keys work same.  j