I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…
Vi is the standard editor that is available on Unix systems.
This visual editor enables manipulation of text while showing a screenful of text unlike ‘sed’ which works at the line level.
Unix Video #12
Modes of Unix Vi Editor
The vi editor has three modes of operation viz. the command mode, the insert mode, and the ex-command mode.
#1) Command mode
In this mode, all the keys work as commands. These keys are used for inserting, appending, deleting, opening new lines, moving the cursor over paragraphs and sentences, etc. In this mode, the keys are not displayed but each key operates.
By default the vi editor is in command mode, hence we cannot type text in command mode. To write programs or text in the vi editors, we need to switch to the insert mode which can be done by pressing the escape button.
#2) Insert mode
In this mode, we can insert, append, edit, or replace texts. We can switch from the command mode to Insert mode by pressing the escape button and then pressing I or A to enter into insert mode.
#3) Ex command mode
This mode is used for entering commands at the bottom line of the vi editor called a command line. To switch to Ex command mode press the escape key then type: (colon). To save the contents and quit from the vi editor press wq after the : (colon). i.e.:wq.
Vi editor saving and quitting commands:
:w -Save the contents of the file.
:q – Quit from vi editors.
:q! -quit from vi editors by discarding any changes.
:wq -Save the file and quit from the vi editor.
This tutorial will cover the various commands that are used in the command and ex-command modes. This includes commands to navigate around the screen by paragraph, line, word, or character.
We will also cover commands for switching the mode and deleting characters, words, lines, or paragraphs.
Our upcoming tutorial will brief more on the Features of Shell Scripting!!
Overview of Pipes in Unix Programming: In this tutorial, we will learn more about Unix Pipes. Later, we will work with some of the remaining filter commands and see an example of piping them together. Unix Video #20: Pipes in Unix A series of filter commands can be piped together…
Introduction to Unix Shell Scripting: In Unix, the Command Shell is the native command interpreter. It provides a command line interface for the users to interact with the operating system. Unix commands may also be executed non-interactively in the form of a Shell Script. The script is a series of…
learn Cut Command in Unix with Simple and Practical Examples: Unix provides a number of filter commands that can be used for processing flat file databases. These filter commands can be chained together to perform a series of operations with a single command. A flat file database is a file…
Introduction to Unix Operating System: Let's start with Tutorial #1: 'What is Unix' in this series. In this tutorial, you will be able to understand the basic concepts of operating systems, the features of Unix, along its Architecture. => Click here for the Complete Unix Tutorial series Unix Video #1:…
Learn Unix Cat Command with Examples: The cat command is perhaps the most commonly used Unix command. It is derived from catenate – which describes the process of connecting things. The cat command is a filter that can be used for multiple purposes: Display the contents of text files. Copy text…
Introduction to Find Command in Unix: Search files and directories with Unix Find File Command The Unix find command is a powerful utility to search for files or directories. The search can be based on different criteria, and the matching files can be run through defined actions. This command recursively…
Overview of Unix Switch Case Statements: In this tutorial, we will see how a switch case block can be used when creating conditional flow depending on the various values of a single expression. Unix Shell The case-esac Statement Unix Video #16: The Shell Switch Case Syntax and Examples: case <word> in…
A beginner's guide to Unix - A complete Unix tutorial series of 20+ in-depth text and video tutorials with hands-on examples. By the end of this series, you will be able to understand the basic and advanced concepts of Unix Architecture, Unix Commands, and applications including File Management, Text Processing,…