0% found this document useful (0 votes)
27 views11 pages

Spring 23-24 Os Lab 7

Uploaded by

ross7geller
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views11 pages

Spring 23-24 Os Lab 7

Uploaded by

ross7geller
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

LAB 7

Course Code: CSC 2209 Course Title: Operating Systems

Dept. of Computer Science


Faculty of Science and Technology

Lecturer No: 07 Week No: 07 Semester: Fall 22-23


Lecturer: Syma Kamal Chaity, [email protected]
Lecture Outline

1. vi Editor
2. Modes of vi Editor
3. Create, Save, and Quit in vi
4. Vi Commands to Start Typing
5. Vi Commands to Move Around a File
6. Vi Commands to Delete Character and Line
7. Vi Commands to cut, copy, and paste
vi Editor
What is vi editor?

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.
Modes of vi Editor
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.
Modes of vi Editor (cont’d)

• 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.
• 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
Create, Save, and Quit in vi
vi syntax to create or open a file: vi fileName
To save file and quit vi editor you can use the given commands below

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 editor Type :wq to save and exit the file.
Vi Commands to Start Typing

Commands 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.
Vi Commands to Move Around a File

commands Action
j To move down
k To move up
h To move left
l To move right
Vi Commands to Delete Character and Line

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
Delete the current line from current character to the
D
end of the line
Vi Commands to cut, copy, and paste

commands Action
dd Delete a line
yy (yank yank) copy a line
P Paste before the current line
p Paste after the current line
Books
❑ Unix Shell Programming
❑ Written by Yashavant P. Kanetkar

You might also like