What is Vi Editor
Vi Editor is a widely used text editor in Unix/Linux systems and is known for its efficiency and flexibility. Vi editor was developed in 1976 by Bill Joy and later in 1991, an improved version of Vi editor was released which is known as VI Improved (VIM).
Modes in Vi Editor
There are two modes in Vi Editor:
- Insert Mode: In this mode, you can directly input and edit text. When in Insert Mode, you can type characters, and add, modify, or delete text content as needed. You can initiate Insert Mode by pressing keys such as ‘i‘ (to insert before the cursor) or ‘a‘ (to insert after the cursor). There are also variations like ‘I‘ (to insert at the beginning of the line) or ‘A‘ (to insert at the end of the line). To exit Insert Mode and return to Command Mode, simply press the ‘Esc‘ key.
- Command Mode: In Command Mode, you navigate and manipulate text without directly typing characters. This mode is designed for controlling the editor’s behavior and performing various editing tasks efficiently. You can move the cursor, delete text, copy and paste, search for text, and execute a wide range of other editing operations using keyboard commands. To transition from Insert Mode to Command Mode, press the ‘Esc‘ key. The clear distinction between these two modes in Vi is a foundational feature that enables users to edit text swiftly and effectively while minimizing the need for complex keyboard shortcuts.
How to Save a File in Vi / Vim Editor & Quit
In this article, we will cover how to save a file in vi editor. First, we look at Linux and Vi editors why we use them, and what their are features then we deep dive into the topic of saving a file and quitting the editor along with the other options, we understand the different commands with an example.