SlideShare a Scribd company logo
Lesson 4-Mastering the Visual Editor
Overview  Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating through a file. Adding text to a file. Avoiding confusion while entering commands to shell and vi.
Overview  Deleting text from a file. Undoing editing commands. Creating new files with the visual editor. Making changes to the text. Moving and copying text. Writing a file and quitting the editor.
Introducing the Visual Editor  Bill Joy, a student of the University of California, wrote the vi editor. The UNIX/Linux visual editor is a powerful, fast, command-driven screen editor. The vi visual editor is available on all systems and is an essential tool. The vi editor allows the movement of cursor to a specific location in a file.
Introducing the Visual Editor  The vi editor is present on every UNIX environment, uses few computing resources, and includes many tools. Standard UNIX releases include vi, and Linux provides vim, which includes some vi improvements. Command mode and append/insert are the two modes of the vi editor.
The command mode allows a user to access a file with basic vi commands. The append/insert mode allows a user to insert data characters in a file. Introducing the Visual Editor
Working in an Existing File with vi  Files are central to the UNIX computing environment. The visual editor is used to create new files and edit existing files. The vi editor does not permit text to be added directly when editing a file. The “cat” utility can be used for creating a file in UNIX.
We can edit the files created by the cat command. We can access/open the files by giving the "vi filename" command. The command will open the files in the command mode. Working in an Existing File with vi
Understanding the Visual Editor  Moving around in a file: Opening a file in vi allows a user to delete, move, copy and paste and save and quit the file. A user cannot insert characters while in the command mode. The fundamental way to move the cursor in a file is to do it with the direction keys.
Understanding the Visual Editor  Moving around in a file (continued): The vi editor interprets the h, j, k, and l keys as a command to the move the cursor in specific directions. The workstation either flashes or beeps if an attempt is made to move the cursor beyond the existing text.
Understanding the Visual Editor  Moving around in the file (continued): The vi editor also provides a forward search command for moving the cursor to a specific word in the text. The /text is the forward search command for moving the cursor to a specified text. The “n” command can be used for locating the next occurrence of a target string specified in the forward search command.
Understanding the Visual Editor  Working with text: To insert characters to the file, we have to change from the command mode to the insert/append mode. The vi editor provides the dd command for deleting an entire line of text from a file. The “dd” command even deletes blank lines.
Understanding the Visual Editor  Working with text (continued): After dd finishes deleting, it remains in the command mode. The “x” (x-out) command deletes only a single character under the cursor. The “a” command switches the vi editor from the command mode to the append mode and allows text to be entered to a file.
Understanding the Visual Editor  Working with text (continued): The “u” command undoes the last text change made to the file. The ESC key instructs the vi editor to switch from the append/insert mode to the command mode. A user can check the mode he is working in with the ESC key. The “o” command tells the editor to open a new blank line between the cursor line and the next line in the file.
Understanding the Visual Editor  Quitting the editor: The “wq” command instructs the editor to write the file and quit the editor. The “q” command can be used for quitting the editor if no changes are made to the file being edited. The “q!” command instructs the editor to quit without saving the changes made to the file.
Understanding the Visual Editor  Creating and reading a file in the editor: A new file can be created in the vi editor by specifying the filename with the vi command. A file opens in the command mode. Text can be entered by switching to the insert/append mode. The “r” or the “read” command locates a file and reads its contents into the current file, starting immediately after the cursor line.
Navigating Through a File  Using the direction keys: The arrow keys and the h, j, k, and l direction keys, either alone or in conjunction with the number keys, make it possible to move the cursor to any character in a file. The “set number” command tells the editor to display the line number on the screen. The commands “G” and “:$” instruct the editor to move to the last line of a file.
Navigating Through a File  Lowercase “n” or “/” (slash) can be used to instruct the vi editor to search forward, whereas uppercase N or ? (question mark) is used to search in the backward direction. The “set ignorecase” command can be used to switch off the case-sensitivity feature of vi’s search mechanism. The “set” command can be used to view the environmental features that are currently set.
Navigating Through a File  The “w” command can be used to advance the cursor to the beginning of the next word. The dollar sign ($) instructs the editor to move the cursor to the end of the current line. The caret (^) and the zero (0) move the cursor to the beginning of a line.
Navigating Through a File  Moving the Cursor in vi
Navigating Through a File  Moving to a Specific Textual Character in vi
Navigating Through a File  Moving the Cursor by Line Address and Location Display
Navigating Through a File  Two single quotation marks instruct the editor to return to the previous location in a file. The display adjustment commands are used to adjust the workstation’s screen display to move forward or backward to a different block or section of code, regardless of its context.
CTRL-F displays the next screen of a text file. CTRL-D scrolls down one half screen of a text file. CTRL-D scrolls up one half screen of a text file. CTRL-B displays the previous screen of a text file. Navigating Through a File
Adding Text to a File  The “i” (insert) command starts adding text to the left of the cursor. The “a” and “i” commands instruct the editor to move from the command mode to the append mode and start adding text at the cursor position. The “O” command is an instruction to open a line above the line where the cursor resides and shift to the append/insert mode.
Adding Text to a File  The “I” command instructs the editor to move the cursor to the beginning of a line and to change to the append mode. The “A” command moves the cursor to the end of a line and switches the editor to the append mode. The I and A command instructs the editor to switch to command mode.
Avoiding Confusion While Entering Commands to Shell and vi  The “who” command, when executed in a shell, lists the users currently logged on. In the vi’s command mode, it moves the cursor to a specific position and moves over to the append mode. In vi’s append mode, the characters are entered directly into the file being edited.
Deleting Text From a File  Multiple lines, words, and characters can be deleted by prefacing the delete command with a number. The uppercase “D” command instructs the editor to delete the remainder of the line starting from the character under the cursor. The “df*” command deletes the text from the cursor to the first character * on the current line to the right of the cursor.
Deleting Text From a File  The vi editor also allows lines to be deleted using the line number addresses. The d command also allows a comma to be used for specifying a range of lines to be deleted. Commands that employ line addresses require the ENTER key to be pressed after the command for execution.
Undoing Editing Commands  The “u” command undoes the last editing change in the file. The vi editor in Linux allows multiple changes to be undone. The “U” command undoes any number of changes made to the current line where the cursor is located.
Creating New Files with the Visual  Editor  The vi filename command is used for creating a new file as well as editing an existing file. The vi makes a buffer copy of a file if it exists, else it starts editing a memory buffer using the new filename. A file created in vi can be made executable by executing the chmod command.
Making Changes to the Text The “r” command instructs the editor to replace the character located under the cursor with the very next character typed in by the user. It can also be used for breaking up a long line into parts. The uppercase “J” command can be used for joining two lines of text.
Making Changes to the Text The “R” command switches the editor to the “type-over” mode, wherein each letter typed replaces the character under the cursor as it moves down the line. The “s” command substitutes the character under the cursor with the text typed in by the user until the ESC key is pressed. The “cw” (change word) command allows a user to substitute a word or multitude of words for a single word.
Making Changes to the Text The “cc” command deletes the text from the current line and moves you from the command mode to the append mode. The “C” command puts the editor into the append mode and allows a user to change part of the line from the cursor position to the end of the line. The substitute command, a colon command, is used to exchange one regular expression for another in a file.
Making Changes to the Text The substitute command requires two words to be separated by slashes. The “g” at the end of the substitute command is a flag and can be used for replacing all occurrences of the target pattern with the addressed lines. The substitute command can also be restricted to lines having specific content.
Moving and Copying Text  The “yy” command instructs the editor to copy the contents of the line where the cursor resides. The “p” or “P” command is used for pasting a new line in a new location below the cursor line. The dd and p commands can be combined to perform a cut and paste operation.
Moving and Copying Text  Commands to Move and Copy Text
Moving and Copying Text  Marking a place in the file: The “m*” command instructs the editor to mark a line of text and assign it a label specified in the *; it can have a value from a to z. A single quote character with the label name can be used for moving on to a specific label. Vi allows deleting, changing, and yanking of text from the current position to the marked spot.
Moving and Copying Text  The delete, change, and yank commands
Moving and Copying Text  Marking a place in the file (continued): The mark command can also be used for simplifying the tasks of deleting, moving, and copying large blocks of text by marking both ends of the block. Marking text is a powerful way to identify lines to delete, move, or copy. The move or copy commands can be used for moving or copying a block of text specified using line numbers.
Writing a File and Quitting the  Editor  The “w” command can be used for saving a copy of the current file to a new file. The w or write command can also be used for writing a part or block of text from the current file to a new file.
The “w!” command instructs the editor to overwrite the contents of the file if it exists, else creates a new file for saving the contents of the current file. The >> symbol, when specified with the w command, appends the text to the file specified. Writing a File and Quitting the  Editor
Summary  The vi is the editor used to create and edit files. Vi provides several utilities to edit text. Append/insert and command are the two modes of the vi editor. Files created in the cat command can be opened in vi.
Summary  A user cannot insert data without switching to the append/insert mode. The I, a, i, A, o, and O commands instruct the editor to add text relative to the cursor position. The vi editor provides the change (c), yank (y), and delete (d) operators for text operations.
Summary  The vi provides various utilities to move, edit, delete, and replace text. The :wq is used for saving and quitting the editor. The vi editor facilitates global changes, where the user specifies the target for replacement and the replacement text. Linux provides an advanced version of the vi, namely the vim editor.
Ad

Recommended

intro unix/linux 05
intro unix/linux 05
duquoi
 
intro unix/linux 06
intro unix/linux 06
duquoi
 
intro unix/linux 08
intro unix/linux 08
duquoi
 
intro unix/linux 03
intro unix/linux 03
duquoi
 
intro unix/linux 10
intro unix/linux 10
duquoi
 
intro unix/linux 02
intro unix/linux 02
duquoi
 
intro unix/linux 11
intro unix/linux 11
duquoi
 
intro unix/linux 07
intro unix/linux 07
duquoi
 
intro unix/linux 09
intro unix/linux 09
duquoi
 
Linuxs1
Linuxs1
rajikaa
 
08. handling file streams
08. handling file streams
Haresh Jaiswal
 
Spsl unit1
Spsl unit1
Sasidhar Kothuru
 
Shell scripting
Shell scripting
DeepakKumar4980
 
File Pointers
File Pointers
Kulachi Hansraj Model School Ashok Vihar
 
File handling in c++
File handling in c++
Daniel Nyagechi
 
working file handling in cpp overview
working file handling in cpp overview
gourav kottawar
 
Linux
Linux
merlin deepika
 
Linux
Linux
Yuvaraja Rajenderan
 
Linux com
Linux com
MohanKumar Palanichamy
 
Filehandlinging cp2
Filehandlinging cp2
Tanmay Baranwal
 
File Handling In C++
File Handling In C++
Kulachi Hansraj Model School Ashok Vihar
 
Spsl by sasidhar 3 unit
Spsl by sasidhar 3 unit
Sasidhar Kothuru
 
File handling in_c
File handling in_c
sanya6900
 
File handling in C++
File handling in C++
Hitesh Kumar
 
2CPP17 - File IO
2CPP17 - File IO
Michael Heron
 
Ch05
Ch05
Mike Qaissaunee
 
C++ Files and Streams
C++ Files and Streams
Ahmed Farag
 
File in cpp 2016
File in cpp 2016
Dr .Ahmed Tawwab
 
1_Editors_in_Unix
1_Editors_in_Unix
Gautam Raja
 
Vi editor
Vi editor
Ramakrishna kapa
 

More Related Content

What's hot (20)

intro unix/linux 09
intro unix/linux 09
duquoi
 
Linuxs1
Linuxs1
rajikaa
 
08. handling file streams
08. handling file streams
Haresh Jaiswal
 
Spsl unit1
Spsl unit1
Sasidhar Kothuru
 
Shell scripting
Shell scripting
DeepakKumar4980
 
File Pointers
File Pointers
Kulachi Hansraj Model School Ashok Vihar
 
File handling in c++
File handling in c++
Daniel Nyagechi
 
working file handling in cpp overview
working file handling in cpp overview
gourav kottawar
 
Linux
Linux
merlin deepika
 
Linux
Linux
Yuvaraja Rajenderan
 
Linux com
Linux com
MohanKumar Palanichamy
 
Filehandlinging cp2
Filehandlinging cp2
Tanmay Baranwal
 
File Handling In C++
File Handling In C++
Kulachi Hansraj Model School Ashok Vihar
 
Spsl by sasidhar 3 unit
Spsl by sasidhar 3 unit
Sasidhar Kothuru
 
File handling in_c
File handling in_c
sanya6900
 
File handling in C++
File handling in C++
Hitesh Kumar
 
2CPP17 - File IO
2CPP17 - File IO
Michael Heron
 
Ch05
Ch05
Mike Qaissaunee
 
C++ Files and Streams
C++ Files and Streams
Ahmed Farag
 
File in cpp 2016
File in cpp 2016
Dr .Ahmed Tawwab
 

Similar to intro unix/linux 04 (20)

1_Editors_in_Unix
1_Editors_in_Unix
Gautam Raja
 
Vi editor
Vi editor
Ramakrishna kapa
 
Vi Vi Editor Unit 4 Power point presentation
Vi Vi Editor Unit 4 Power point presentation
jatinlntcdc
 
Linux Text Editor (Vi) Command List Summary
Linux Text Editor (Vi) Command List Summary
minzo1988minzawoo
 
Qc document draft
Qc document draft
gourabehera
 
Vi Editor
Vi Editor
Shiwang Kalkhanda
 
VI Editors
VI Editors
Deivanai
 
07 vi text_editor
07 vi text_editor
Shay Cohen
 
Vi editor in linux
Vi editor in linux
Bhumivaghasiya
 
Vi editor
Vi editor
Nidhi Sharma
 
Linux text editors
Linux text editors
InfoExcavator
 
Linux text editors Vim nano
Linux text editors Vim nano
Md Meherab Hossen
 
VI editor in unix
VI editor in unix
Ahmed Fayyaz
 
Using VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit Kumar
Rohit Kumar
 
Using vi editor
Using vi editor
Rohit Kumar
 
Vi editor Linux Editors
Vi editor Linux Editors
TONO KURIAKOSE
 
lectuer 21-22.pptx
lectuer 21-22.pptx
poonam256394
 
VI Editor - R.D.Sivakumar
VI Editor - R.D.Sivakumar
Sivakumar R D .
 
Vi editor commands
Vi editor commands
Femi Adeyemi
 
Introduction to vi editor
Introduction to vi editor
U.P Police
 
1_Editors_in_Unix
1_Editors_in_Unix
Gautam Raja
 
Vi Vi Editor Unit 4 Power point presentation
Vi Vi Editor Unit 4 Power point presentation
jatinlntcdc
 
Linux Text Editor (Vi) Command List Summary
Linux Text Editor (Vi) Command List Summary
minzo1988minzawoo
 
Qc document draft
Qc document draft
gourabehera
 
VI Editors
VI Editors
Deivanai
 
07 vi text_editor
07 vi text_editor
Shay Cohen
 
Linux text editors Vim nano
Linux text editors Vim nano
Md Meherab Hossen
 
VI editor in unix
VI editor in unix
Ahmed Fayyaz
 
Using VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit Kumar
Rohit Kumar
 
Vi editor Linux Editors
Vi editor Linux Editors
TONO KURIAKOSE
 
lectuer 21-22.pptx
lectuer 21-22.pptx
poonam256394
 
VI Editor - R.D.Sivakumar
VI Editor - R.D.Sivakumar
Sivakumar R D .
 
Vi editor commands
Vi editor commands
Femi Adeyemi
 
Introduction to vi editor
Introduction to vi editor
U.P Police
 
Ad

More from duquoi (9)

Troubleshooting CD Burning
Troubleshooting CD Burning
duquoi
 
Advanced Bash Scripting Guide 2002
Advanced Bash Scripting Guide 2002
duquoi
 
Astrolog: Switches
Astrolog: Switches
duquoi
 
Cinelerra Video Editing Manual
Cinelerra Video Editing Manual
duquoi
 
Iptables
Iptables
duquoi
 
Ffmpeg
Ffmpeg
duquoi
 
rosegarden
rosegarden
duquoi
 
intro unix/linux 12
intro unix/linux 12
duquoi
 
intro unix/linux 01
intro unix/linux 01
duquoi
 
Troubleshooting CD Burning
Troubleshooting CD Burning
duquoi
 
Advanced Bash Scripting Guide 2002
Advanced Bash Scripting Guide 2002
duquoi
 
Astrolog: Switches
Astrolog: Switches
duquoi
 
Cinelerra Video Editing Manual
Cinelerra Video Editing Manual
duquoi
 
Iptables
Iptables
duquoi
 
Ffmpeg
Ffmpeg
duquoi
 
rosegarden
rosegarden
duquoi
 
intro unix/linux 12
intro unix/linux 12
duquoi
 
intro unix/linux 01
intro unix/linux 01
duquoi
 
Ad

Recently uploaded (20)

Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 

intro unix/linux 04

  • 1. Lesson 4-Mastering the Visual Editor
  • 2. Overview Introducing the visual editor. Working in an existing file with vi. Understanding the visual editor. Navigating through a file. Adding text to a file. Avoiding confusion while entering commands to shell and vi.
  • 3. Overview Deleting text from a file. Undoing editing commands. Creating new files with the visual editor. Making changes to the text. Moving and copying text. Writing a file and quitting the editor.
  • 4. Introducing the Visual Editor Bill Joy, a student of the University of California, wrote the vi editor. The UNIX/Linux visual editor is a powerful, fast, command-driven screen editor. The vi visual editor is available on all systems and is an essential tool. The vi editor allows the movement of cursor to a specific location in a file.
  • 5. Introducing the Visual Editor The vi editor is present on every UNIX environment, uses few computing resources, and includes many tools. Standard UNIX releases include vi, and Linux provides vim, which includes some vi improvements. Command mode and append/insert are the two modes of the vi editor.
  • 6. The command mode allows a user to access a file with basic vi commands. The append/insert mode allows a user to insert data characters in a file. Introducing the Visual Editor
  • 7. Working in an Existing File with vi Files are central to the UNIX computing environment. The visual editor is used to create new files and edit existing files. The vi editor does not permit text to be added directly when editing a file. The “cat” utility can be used for creating a file in UNIX.
  • 8. We can edit the files created by the cat command. We can access/open the files by giving the "vi filename" command. The command will open the files in the command mode. Working in an Existing File with vi
  • 9. Understanding the Visual Editor Moving around in a file: Opening a file in vi allows a user to delete, move, copy and paste and save and quit the file. A user cannot insert characters while in the command mode. The fundamental way to move the cursor in a file is to do it with the direction keys.
  • 10. Understanding the Visual Editor Moving around in a file (continued): The vi editor interprets the h, j, k, and l keys as a command to the move the cursor in specific directions. The workstation either flashes or beeps if an attempt is made to move the cursor beyond the existing text.
  • 11. Understanding the Visual Editor Moving around in the file (continued): The vi editor also provides a forward search command for moving the cursor to a specific word in the text. The /text is the forward search command for moving the cursor to a specified text. The “n” command can be used for locating the next occurrence of a target string specified in the forward search command.
  • 12. Understanding the Visual Editor Working with text: To insert characters to the file, we have to change from the command mode to the insert/append mode. The vi editor provides the dd command for deleting an entire line of text from a file. The “dd” command even deletes blank lines.
  • 13. Understanding the Visual Editor Working with text (continued): After dd finishes deleting, it remains in the command mode. The “x” (x-out) command deletes only a single character under the cursor. The “a” command switches the vi editor from the command mode to the append mode and allows text to be entered to a file.
  • 14. Understanding the Visual Editor Working with text (continued): The “u” command undoes the last text change made to the file. The ESC key instructs the vi editor to switch from the append/insert mode to the command mode. A user can check the mode he is working in with the ESC key. The “o” command tells the editor to open a new blank line between the cursor line and the next line in the file.
  • 15. Understanding the Visual Editor Quitting the editor: The “wq” command instructs the editor to write the file and quit the editor. The “q” command can be used for quitting the editor if no changes are made to the file being edited. The “q!” command instructs the editor to quit without saving the changes made to the file.
  • 16. Understanding the Visual Editor Creating and reading a file in the editor: A new file can be created in the vi editor by specifying the filename with the vi command. A file opens in the command mode. Text can be entered by switching to the insert/append mode. The “r” or the “read” command locates a file and reads its contents into the current file, starting immediately after the cursor line.
  • 17. Navigating Through a File Using the direction keys: The arrow keys and the h, j, k, and l direction keys, either alone or in conjunction with the number keys, make it possible to move the cursor to any character in a file. The “set number” command tells the editor to display the line number on the screen. The commands “G” and “:$” instruct the editor to move to the last line of a file.
  • 18. Navigating Through a File Lowercase “n” or “/” (slash) can be used to instruct the vi editor to search forward, whereas uppercase N or ? (question mark) is used to search in the backward direction. The “set ignorecase” command can be used to switch off the case-sensitivity feature of vi’s search mechanism. The “set” command can be used to view the environmental features that are currently set.
  • 19. Navigating Through a File The “w” command can be used to advance the cursor to the beginning of the next word. The dollar sign ($) instructs the editor to move the cursor to the end of the current line. The caret (^) and the zero (0) move the cursor to the beginning of a line.
  • 20. Navigating Through a File Moving the Cursor in vi
  • 21. Navigating Through a File Moving to a Specific Textual Character in vi
  • 22. Navigating Through a File Moving the Cursor by Line Address and Location Display
  • 23. Navigating Through a File Two single quotation marks instruct the editor to return to the previous location in a file. The display adjustment commands are used to adjust the workstation’s screen display to move forward or backward to a different block or section of code, regardless of its context.
  • 24. CTRL-F displays the next screen of a text file. CTRL-D scrolls down one half screen of a text file. CTRL-D scrolls up one half screen of a text file. CTRL-B displays the previous screen of a text file. Navigating Through a File
  • 25. Adding Text to a File The “i” (insert) command starts adding text to the left of the cursor. The “a” and “i” commands instruct the editor to move from the command mode to the append mode and start adding text at the cursor position. The “O” command is an instruction to open a line above the line where the cursor resides and shift to the append/insert mode.
  • 26. Adding Text to a File The “I” command instructs the editor to move the cursor to the beginning of a line and to change to the append mode. The “A” command moves the cursor to the end of a line and switches the editor to the append mode. The I and A command instructs the editor to switch to command mode.
  • 27. Avoiding Confusion While Entering Commands to Shell and vi The “who” command, when executed in a shell, lists the users currently logged on. In the vi’s command mode, it moves the cursor to a specific position and moves over to the append mode. In vi’s append mode, the characters are entered directly into the file being edited.
  • 28. Deleting Text From a File Multiple lines, words, and characters can be deleted by prefacing the delete command with a number. The uppercase “D” command instructs the editor to delete the remainder of the line starting from the character under the cursor. The “df*” command deletes the text from the cursor to the first character * on the current line to the right of the cursor.
  • 29. Deleting Text From a File The vi editor also allows lines to be deleted using the line number addresses. The d command also allows a comma to be used for specifying a range of lines to be deleted. Commands that employ line addresses require the ENTER key to be pressed after the command for execution.
  • 30. Undoing Editing Commands The “u” command undoes the last editing change in the file. The vi editor in Linux allows multiple changes to be undone. The “U” command undoes any number of changes made to the current line where the cursor is located.
  • 31. Creating New Files with the Visual Editor The vi filename command is used for creating a new file as well as editing an existing file. The vi makes a buffer copy of a file if it exists, else it starts editing a memory buffer using the new filename. A file created in vi can be made executable by executing the chmod command.
  • 32. Making Changes to the Text The “r” command instructs the editor to replace the character located under the cursor with the very next character typed in by the user. It can also be used for breaking up a long line into parts. The uppercase “J” command can be used for joining two lines of text.
  • 33. Making Changes to the Text The “R” command switches the editor to the “type-over” mode, wherein each letter typed replaces the character under the cursor as it moves down the line. The “s” command substitutes the character under the cursor with the text typed in by the user until the ESC key is pressed. The “cw” (change word) command allows a user to substitute a word or multitude of words for a single word.
  • 34. Making Changes to the Text The “cc” command deletes the text from the current line and moves you from the command mode to the append mode. The “C” command puts the editor into the append mode and allows a user to change part of the line from the cursor position to the end of the line. The substitute command, a colon command, is used to exchange one regular expression for another in a file.
  • 35. Making Changes to the Text The substitute command requires two words to be separated by slashes. The “g” at the end of the substitute command is a flag and can be used for replacing all occurrences of the target pattern with the addressed lines. The substitute command can also be restricted to lines having specific content.
  • 36. Moving and Copying Text The “yy” command instructs the editor to copy the contents of the line where the cursor resides. The “p” or “P” command is used for pasting a new line in a new location below the cursor line. The dd and p commands can be combined to perform a cut and paste operation.
  • 37. Moving and Copying Text Commands to Move and Copy Text
  • 38. Moving and Copying Text Marking a place in the file: The “m*” command instructs the editor to mark a line of text and assign it a label specified in the *; it can have a value from a to z. A single quote character with the label name can be used for moving on to a specific label. Vi allows deleting, changing, and yanking of text from the current position to the marked spot.
  • 39. Moving and Copying Text The delete, change, and yank commands
  • 40. Moving and Copying Text Marking a place in the file (continued): The mark command can also be used for simplifying the tasks of deleting, moving, and copying large blocks of text by marking both ends of the block. Marking text is a powerful way to identify lines to delete, move, or copy. The move or copy commands can be used for moving or copying a block of text specified using line numbers.
  • 41. Writing a File and Quitting the Editor The “w” command can be used for saving a copy of the current file to a new file. The w or write command can also be used for writing a part or block of text from the current file to a new file.
  • 42. The “w!” command instructs the editor to overwrite the contents of the file if it exists, else creates a new file for saving the contents of the current file. The >> symbol, when specified with the w command, appends the text to the file specified. Writing a File and Quitting the Editor
  • 43. Summary The vi is the editor used to create and edit files. Vi provides several utilities to edit text. Append/insert and command are the two modes of the vi editor. Files created in the cat command can be opened in vi.
  • 44. Summary A user cannot insert data without switching to the append/insert mode. The I, a, i, A, o, and O commands instruct the editor to add text relative to the cursor position. The vi editor provides the change (c), yank (y), and delete (d) operators for text operations.
  • 45. Summary The vi provides various utilities to move, edit, delete, and replace text. The :wq is used for saving and quitting the editor. The vi editor facilitates global changes, where the user specifies the target for replacement and the replacement text. Linux provides an advanced version of the vi, namely the vim editor.