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

Lab Assignment 2 Monday

The document provides instructions for completing Lab Assignment 2 which involves learning basic text editing commands in the Vim text editor by creating and manipulating text in a Vim file. Students are asked to open and edit two files using Vim commands for navigation, insertion, deletion, copying, pasting, saving and quitting. The final task is to set up a Vim file, enter and edit text using Vim commands, and then open and manipulate a second file.

Uploaded by

BassGod
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Lab Assignment 2 Monday

The document provides instructions for completing Lab Assignment 2 which involves learning basic text editing commands in the Vim text editor by creating and manipulating text in a Vim file. Students are asked to open and edit two files using Vim commands for navigation, insertion, deletion, copying, pasting, saving and quitting. The final task is to set up a Vim file, enter and edit text using Vim commands, and then open and manipulate a second file.

Uploaded by

BassGod
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

School of Computer Science Engineering and Technology

Course- BTech Type- Core


Course Code- CSET209 Course Name- Operating Systems (OS)
Year- 2024 Semester- Even
Date- 22/01/2024 Batch- 2022-2026

Lab Assignment No. 2


Objective: To learn and execute basic text editing commands using Vim editor.
Background: Vim, an acronym for ‘Vi Improved’, is a highly configurable and efficient text
editor that is widely used in the Linux and Unix environments. It is an extended and improved
version of the original Vi editor, incorporating additional features and enhancements.
Learning and using basic text editing commands in Vim Editor can be highly practical,
especially if you often work in a command-line environment or on remote servers where a
graphical text editor may not be available. Vim Editor is a powerful and efficient text editor
that comes pre-installed on many Linux/Unix-based systems. A step-by-step guide to help you
get started with Vim Editor is as follows.

1. Opening a File:
To open a file using Vim, open your terminal and type:
vim filename
Replace "filename" with the name of the file you want to edit.

2. Modes:
Vim Editor has different modes. The two main modes are:
• Normal mode (default): Used for navigation and manipulation.
• Insert mode: Used for inserting or editing text.
To switch from Normal mode to Insert mode, press ‘i’. To switch back to Normal mode,
press ‘Esc’.

3. Navigation:
Following points will be helpful for navigation in Vim Editor.
• Use the arrow keys to move the cursor.
• ‘h’, ‘j’, ‘k’, ‘l’ for left, down, up, and right respectively.
• ‘Ctrl + f’ for page down and ‘Ctrl + b’ for page up.
• ‘$’ to move to the end of a line, ‘0’ (zero) to move to the beginning.
4. Editing:
• Inserting text:
o Switch to Insert mode ‘i’ and start typing.
o Press ‘Esc’ to return to Normal mode.
• Deleting text:
o ‘x’ deletes the character under the cursor.
o ‘dd’ deletes the entire line.
• Undo and redo:
o ‘u’ for undo, ‘Ctrl + r’ for redo in Normal mode.

5. Saving and Quitting:


• Save changes:
o While in Normal mode, type ‘:w’ and press ‘Enter’.
• Save and quit:
o While in Normal mode, type ‘:wq’ and press ‘Enter’.
• Quit without saving:
o While in Normal mode, type ‘:q!’ and press ‘Enter’.

6. Search and Replace:


• Search:
o ‘/’ followed by the search term and press ‘Enter’.
o To find the next occurrence, press ‘n’.
• Replace:
o ‘:%s/old/new/g’ to replace all occurrences of ‘old’ with ‘new’.

7. Copy, Cut, Paste:


• Copy (Yank):
o ‘y’ followed by a movement command. For example, ‘yy’ yanks a line.
• Cut (Delete):
o d followed by a movement command. For example, dd deletes a line.
• Paste:
o p to paste after the cursor, P to paste before the cursor.

8. Exiting Vim:
If you are stuck or accidentally entered command mode without intending to, you can always
type ‘:q!’ to quit without saving changes.

The above information will be helpful to solve Lab Assignment 2.


Final Task for submission:
Setting Up a Vim Editor File and Manipulate Text
Instructions:
1. Create a Vim Editor file:
• Create a Vim Editor file with the name as: yourFirstname_EnrolmentID.txt
• The file will open, press ‘Ctrl+z’ to close and come back to the terminal.

2. Verify File Creation:


• Run ‘ls’ to verify your created file.

3. Navigate to the Created File:


• Open the created file (yourFirstname_EnrolmentID.txt)
• This file will be a blank file, as of now.

4. Entering the Insert mode:


• Enter in the insert mode and write your short biography.

5. Saving the Work:


• Save your entered text.

6. Moving the cursor around:


• Try moving the cursor in different positions

7. Cut/Deleting the text:


• Try the suitable commands to cut or delete the text.

8. Undone the entered text:


• Delete some random text.
• Try undone the deleted text.

9. Copy/Paste the text:


• Try to copy some random text.
• Paste the text in same/different location in the same file.

10. Open the file Dataset1_facial_recog.txt using vim editor and perform all the above
operations.

You might also like