how to Enter in Editing Mode in VI Editor
Last Updated :
17 Sep, 2024
The Vi editor, short for "Visual Editor," is a powerful and widely used text editor in the Unix and Linux operating systems. Vi offers various modes for text manipulation, including command mode, insert mode, and visual mode. In this article, we will focus on entering the editing mode, which is essential for making changes to your text files in Vi.
What is Vi Editor?
Vi, developed in the late 1970s, remains one of the most widely used text editors due to its availability on nearly all Unix-like systems and its powerful, modal interface. Unlike modern text editors, Vi does not have a graphical user interface; instead, it relies solely on keyboard commands, which, once mastered, can make editing tasks incredibly fast and efficient.
Steps to enter the editing mode in VI
To effectively edit files in Vi, you need to transition smoothly between modes. Follow these steps to enter editing mode and start making changes to your text files:
Step 1: Open a File in Vi
To start editing a file with Vi, open your terminal.
Type the following command: vi filename, replacing "filename" with the name of the file you want to edit. If the file doesn't exist, Vi will create a new one with the provided name.
vi filename
Replace "filename" with the name of the file you want to edit. If the file does not exist, Vi will create a new one with the provided name.
Step 2: Navigate to Command Mode
When you open a file in Vi, you start in the command mode. In this mode, you can issue commands to navigate, save, and manipulate text. To ensure you are in command mode, press the Esc key. This step is crucial because you cannot enter text in other modes.

Step 3: Enter Insert Mode
To enter insert mode, which allows you to add or modify text, press one of the following keys while in command mode:
Option | Description |
---|
i | Start inserting text before the current cursor position. |
---|
I | Start inserting text at the beginning of the current line. |
---|
a | Start inserting text after the current cursor position. |
---|
A | Start inserting text at the end of the current line. |
---|
o | Open a new line below the current line and enter insert mode. |
---|
O | Open a new line above the current line and enter insert mode. |
---|

Each of these commands offers flexibility in how you begin editing, whether you’re appending text, inserting at the start, or adding new lines.
Step 4: Editing Your Text
Once you are in insert mode, you can freely type and edit your text. Make the necessary changes, additions, or deletions as required.

Step 5: Return to Command Mode
After you have made your edits, press the Esc key to return to command mode. This step is vital because it allows you to save or exit the file.
Step 6: Save and Exit
To save your changes and exit Vi, use the following command in command mode:
:wq

You will not be able to quit if you do not use "!" .

Step 7: Discard Changes and Exit
If you made changes but wish to discard them and exit Vi, use the following command in command mode:
:q!
Common Mistakes to Avoid
- Accidentally Entering the Wrong Mode: Always press Esc to return to Command mode and start over.
- Not Saving Changes: Always remember to save your work with ':w' or ':wq'.
- Getting Stuck in Vi: The ':q!' command can force quit without saving, useful when you're overwhelmed by unintended changes.
Conclusion
In conclusion, mastering the Vi text editor's editing mode is a valuable skill for anyone working in Unix and Linux environments. By following the above mentioned steps, you can have a seamless transition between modes, insert and edit text with precision, and efficiently manage your text files. As you practice and become more familiar with Vi's commands, you'll gain confidence in your ability to navigate and manipulate text swiftly and effectively.
Similar Reads
Editing Mode | Insert Mode in Vim Editor
This article will cover how to enter editing mode in Vim editor. First, we look at what Linux and VIM editors are and why we use them, followed by commands to enter editing mode in Vim editor along and examples and screenshots. LinuxLinux was developed by Linus Torvalds in 1991 as a hobby project. I
5 min read
How to Edit Multiple Files in Vi Editor in Linux
Vi, short for "visual editor," is a powerful and ubiquitous text editor in the Linux ecosystem. Among its many features, one of the most useful is its capability to edit multiple files simultaneously. This ability streamlines the editing process, especially when dealing with projects that span multi
4 min read
How to Edit Multiple Files in Vim Editor in Linux
Vim, short for "Vi Improved," is a highly configurable and powerful text editor built upon the foundation of Vi. Like its predecessor, Vim offers robust support for editing multiple files simultaneously, making it an indispensable tool for developers, system administrators, and anyone working extens
4 min read
How to Indent Code in Vim Editor?
Vim is a popular text editor used by many developers for writing code, creating readme files, and writing scripts. It's open-source and offers a lot of ways to customize your experience. This makes it easier and more efficient to work with. Properly formatting and indenting your code is important be
4 min read
How to Delete Multiple Lines in Vi editor
Linux was developed by Linus Torvalds in 1991 as a hobby project. It is an open-source (source code that can be used by anyone freely) kernel that is most popular and widely used in the industry as well as in personal systems. There are various operating systems based on the Linux kernel, some of th
5 min read
How to Hide Line Numbers in Vim Editor
In this article, we will cover how to hide line numbers in the Vim editor. First, we look at what Linux and VIM editors and why we use them, what are its features and how can we use them followed by various options to make the Vim editor hide line numbers and how we can change the default settings o
3 min read
How to Install Vim Editor in MacOS?
Vim editor is an open-source software developed by "Bram Moolenaar" in 1991. Vim, short for "Vi IMproved," is a highly customizable and powerful text editor that is most commonly used by developers, system administrators, writers, and anyone who works extensively with text files. Vim is created as a
3 min read
How to Paste in Vim Editor from Notepad?
Vim is a robust text editor found in many Unix-like systems. Copying text from an external source, such as Notepad, and copying it into Vim can be challenging, especially for inexperienced users. In normal mode, every character entered will be read as a command in Vim. Place the cursor where you wan
4 min read
How to Delete Line in Nano Editor?
In a terminal environment, Nano is a straightforward and widely used text editor for Linux and macOS systems. Deleting lines in Nano is a basic yet essential operation, allowing for efficient editing within files. By following simple keyboard shortcuts like "Ctrl+K," you can swiftly remove lines fro
5 min read
How to Save and Exit in Nano Editor in linux
Saving and exiting in the Nano text editor in Linux is a fundamental skill for anyone working with text files in the terminal. Nano is a user-friendly and straightforward text editor, making it an excellent choice for both beginners and experienced Linux users. Whether you're editing configuration f
5 min read