0% found this document useful (0 votes)
67 views

COURSE: Operating System For Novice TOPIC: Using Text Editor - VI Lab No: 2 Duration: 2H

This document provides instructions for a lab exercise on using the vi text editor. The objectives are to have students create and edit text files using vi as well as use shortcut keys. It includes notes on vi, commands for creating and editing text, inserting text, deleting text, searching text, and leaving vi. Exercises are provided for students to practice these skills and commands.

Uploaded by

Dharvin Daran
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)
67 views

COURSE: Operating System For Novice TOPIC: Using Text Editor - VI Lab No: 2 Duration: 2H

This document provides instructions for a lab exercise on using the vi text editor. The objectives are to have students create and edit text files using vi as well as use shortcut keys. It includes notes on vi, commands for creating and editing text, inserting text, deleting text, searching text, and leaving vi. Exercises are provided for students to practice these skills and commands.

Uploaded by

Dharvin Daran
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/ 3

COURSE: Operating System for Novice

TOPIC: Using text editor - VI

LAB No : 2 DURATION: 2H

Instruction:
1. Read and follow the simple notes given
2. Do the exercise given

Lab exercises outcome:

At the end of this lab section students will be able to:


1. Create and edit text using vi text editor.
2. Use shortcut keys to edit the vi files.

Creating text from text editor – VI

Notes

The vi editor is available on almost all Unix systems. vi can be used from any type of terminal
because it does not depend on arrow keys and function keys--it uses the standard alphabetic
keys for commands.

vi (pronounced "vee-eye") is short for "vi"sual editor. It displays a window into the file being edited
that shows 24 lines of text. vi is a text editor, not a "what you see is what you get" word processor.
vi lets you add, change, and delete text, but does not provide such formatting capabilities as
centering lines or indenting paragraphs.

Edit File in vi editor: Practice following commands

(i) Creating & Editing a file with vi Editor.


No. Purpose Command
1 Use editor to create a new file, replacing vi <Filename>. vi Lab2
<filename> with the name of your file
2 Switch to input mode. Default mode when Key “i” to append
opening the vi editor is command mode

vi has two modes:

command mode
insert mode

In command mode, the letters of the keyboard


perform editing functions (like moving the cursor,
deleting text, etc.). To enter command mode,
press the escape <Esc> key.
COURSE: Operating System for Novice
TOPIC: Using text editor - VI

LAB No : 2 DURATION: 2H

In insert mode, the letters you type form words


and sentences. Unlike many word processors, vi
starts up in command mod
3 Type few words My First Vi File
4 Exit input mode. Notice that no change at the ESC
curser
5 Practice moving cursor in all four directions Arrow keys or H,J,K,L
6 Save your work and end the editing session :w to save. :q to quit terminal. :wq
to execute both command
together

(ii) Inserting text


No. Purpose Command
1 Edit the already created file vi <Filename>
2 Add a new line to the bottom of the cursor. Key Locate position, Key “o”. CCA22001.
in your ID number Esc
3 Add a new line to the top of the cursor. Key in Locate position, Key “O”. Steve Jobs.
your name Esc
5 Add a new word to the beginning of a line Locate position, Key “I”, Esc
6 Add a new word to the end of a line Locate position, Key “A”, Esc
7 Insert before the cursor Locate position, Key “a”, Esc
8 Insert after the cursor Locate position, Key “i”, Esc
9 Save your work and end the editing session :wq

(iii) Deleting text


No. Purpose Command
1 Edit the already created file vi <Filename>
2 Delete some characters in a line Locate position, Key “x”
3 Delete a line Locate position, Key “dd”
4 Delete a word Locate position, Key “dw”
5 Delete 2 lines Locate position, Key “2dd”
6 Save your work and end the editing session :wq

Type the followings in Lab2 before continuing to the next exercise.

“The recent research activities in the field of nonlinear dynamics and especially on systems with
complex (chaotic) behavior have forced a lot of investigations on possible applications of such
systems. Among them also the field of chaotic encryption appeared. While initially the publications
on chaotic encryption were discussed also in the community of applied cryptography [1]–[4], this
interdisciplinary debate seems to have ceased. Today, chaotic encryption is almost exclusively
considered inside the nonlinear systems community.”
COURSE: Operating System for Novice
TOPIC: Using text editor - VI

LAB No : 2 DURATION: 2H

(i) Searching & Undo


No Purpose Command
1 Edit the already created file vi <Filename>
2 Search forward for a pattern. Search Locate position at the beginning of the text, Key
for the word encryption “/” followed by pattern, n for next
3 Search backward for a pattern. Locate position at the end of the text, Key “?”
Search for the word encryption followed by pattern, n for next
4 Delete a line Locate position, Key “dd”
5 Undo the delete Key “u”
6 Input a line Locate position, Key “o” or “O”, Esc
7 Undo the input Key “u”
8 Save your work and end the editing :wq
session

(ii) Leaving vi
No. Purpose Command
1 Edit the already created file vi <Filename>
2 Add some words a or i
3 save :w, Enter
4 Quit vi :q, Enter
5 Edit the file again vi <Filename>
6 Add some lines O, o , a or i
7 Quit vi with save :wq, Enter
8 Input a line Locate position, Key “o” or “O”, Esc
9 Quit vi without save :q!, Enter

(iii) Try it your self


No. Purpose Command
1 Create a file called ‘Myself’
2 In that file, write down your profile such as
1. Name :
2. Address :
3. How do you see yourself in 4 years :
3 Save the file and exit vi mode
4 Display the content of your file

You might also like