BCA / B.Tech 10 min read

The `vi` Editor and Its Commands

The `vi` Editor and Its Commands in Operating System:


`vi` (Visual Editor) is a primary text editor in the Unix operating system, created by Bill Joy in 1976. It is a screen-based text editor where you can edit text visually. Even today, `vi` is seen as a primary editor on various Unix and Linux systems. It is extremely powerful and flexible, and many system administrators and programmers use it because of its powerful features.

Features of the `vi` Editor:
  • Efficient and Fast: `vi` is a lightweight and fast editor designed to work on low resources.
  • Two Modes: It primarily has two modes: Command Mode (for entering editing commands) and Insert Mode (for directly editing and adding text).
  • Keyboard-based Interface: The editor has no mouse support, but its use with keyboard shortcuts can be very effective.

`vi` Editor Modes:
  • Command Mode: When you open `vi`, you are in this mode. You can navigate and perform various editing operations, but you cannot edit text directly.
  • Insert Mode: In this mode, you can type or edit text. You enter this mode using commands like `i` or `a`.

Commands in the `vi` Editor:

In Command Mode, you can use various commands to navigate, edit text, search, and more. Here are some key commands:
  • Navigation Commands: `h` (left), `l` (right), `k` (up), `j` (down), `0` (start of line), `$` (end of line), `G` (end of file), `gg` (start of file).
  • Insert Commands: `i` (insert at cursor), `a` (append after cursor), `o` (open new line below), `O` (open new line above).
  • Text Editing Commands: `x` (delete character), `dd` (delete line), `D` (delete to end of line), `yy` (copy line), `p` (paste).
  • Search Commands: `/pattern` (search for `pattern`), `n` (next result), `N` (previous result).
  • Save and Exit Commands: `:w` (save), `:q` (quit), `:wq` or `ZZ` (save and quit), `:q!` (quit without saving).
  • Undo Commands: `u` (undo last edit), `U` (undo all changes on the line).

Advantages of `vi` Editor:
  • Effective and Fast: Very fast and works well with low resources.
  • Customizable: Can be customized according to your needs with various plugins and scripts.
  • Available Everywhere: Available in almost every Unix/Linux distribution.

Disadvantages of `vi` Editor:
  • Requires New Habits: Can be difficult to use initially, especially for users accustomed to GUI editors.
  • Lack of Graphical Editing: As a terminal-based editor, it lacks a graphical interface, which can be inconvenient for visual tasks.

In this Chapter

The `vi` Editor and Its Commands
Distributed System in Operating System
Real-Time System in Operating System
System Calls in Operating System
System Programs in Operating System
Structure of an Operating System
Layered Design of an Operating System Structure
UNIX in Operating System
Virtual Machine in Operating System
Kernel-Based Operating System
Process Concept in Operating System
Interacting Processes in Operating System
Threads in Operating System
Fundamentals of Scheduling in Operating System
Scheduling Criteria in Operating System
Long, Medium, and Short-Term Scheduling
Scheduling Algorithms in Operating System
Structure of a Concurrent System
Critical Region in Operating System
Critical Section in Operating System
Inter-process Communication (IPC) in Operating System
Monitors in Operating System
Semaphores in Operating System
Semaphore Implementation & Uses in Operating System
Logical and Physical Address in Operating System
Swapping in Operating System
Contiguous Allocation in Operating System
Segmentation in Operating System
Paging in Operating System
Virtual Memory using Segmentation in Operating System
Interprocess Communication Protocol in Operating System
Network Operating System
Design Issues in Distributed File System
Network Structure in Operating System
Structure of a Distributed System
File System and Coordination in Operating System
History of Linux in Operating System
Linux Commands
Programmer Interface & File Manipulation in Linux
Process Control in Linux
Kernel & Signals in Linux
File System in Linux
Blocks and Inodes in Linux
System Editors in Linux
Character Transliteration in Linux
The `ed` Line Editor in Linux
Shell Scripting in Linux
Looping & Decision Making in Linux Shell Scripting
Variables & File Name Expansion in Linux
Arrays in Linux Shell Scripting
Subprograms (Functions) in Linux Shell Scripting
C Interface with Linux
Simple Shell Programs in Linux
BCA Part-1 | Operating Systems | Semester-I | MDSU Exam Paper 2023 (Held in 2024)
What is an Operating System (OS)
Operating System (OS) All Important Questions and Answers in English (MDSU)
BCA || Operating System 2025 Paper || MDSU Exam Paper
BCA | OS(Operating System) 2023 Paper | MDSU Exam Paper
Types of Operating Systems
Goals of an Operating System
Operations of an Operating System
Resource Allocation & Functions in an Operating System
Classes of Operating System
Batch Processing in Operating System
Multiprocessing in Operating System
Time-Sharing in Operating System