In the Linux world, most work is accomplished from a CLI. One of our main tasks is to manage file content. To accomplish this, we need a tool to edit files. One of the most common editors in the Linux world is the Vi editor, also known as a visual editor. Let's learn about some of the basic Vi operations before looking at my favorite commands.
What is the Vi editor?
A visual editor allows users to write and manipulate text in a file in a Unix-based operating system. An improved version of Vi is called the Vim editor. We can download Vim in Red Hat Enterprise Linux 8 (and similar distributions) by using dnf install -y vim.
How do I use this editor?
Using this editor is quite simple. Type vi file-name, and the editor opens. One advantage of this editor is that we can manipulate text without using a mouse. We only need the keyboard. Let's start this great tool right away.
# vi filename
This command opens up a brand new file named filename. The file looks like this:
Here you see a ~, which means those lines are unused. At the bottom of the page, we see the filename and [New File]. To start writing content into the file, simply press i (insert). Now the file goes to edit mode.
Basic commands
I have written five basic commands that I use with vim:
To copy text, use yy and yw:
yy- Copies the current line.yw- Copies the current word from the character the lowercasewcursor is on, until the end of the word.p- Pastes the copied text.
To move to the start or end of the file:
:1- Moves the cursor to the start of the page.:$- Moves the cursor to the end of the page.
To search for a particular string in the file:
/- For example, if you want to search for the string redhat in a given file, you type:/redhatorred*to take you to the matching string.
To set the line numbers and paste complex texts inside the file:
set num- Sets the line numbers.set paste- Pastes a bulk of text from some other location.
To move forward and backward for one fullscreen:
- Ctrl+f - moves forward by fullscreen.
- Ctrl+b - moves backward by fullscreen.
Intermediate commands
I have written three advanced commands that I use with the Vim editor:
To undo and delete a particular line:
u - Undo the previously executed command.
dd - Deletes the current line of text.
To rename the file:
:f filename - Helps you to rename the file.
To toggle between two open files:
:e # - Helps you to navigate/toggle between two open files.
Conclusion
In this article, I covered the most common commands that I use in my day-to-day work with the Vim editor. By no means does this include all the available commands. Feel free to check the man page for other helpful commands as per your scenario.
[ Free online course: Red Hat Enterprise Linux technical overview. ]
À propos de l'auteur
I work as a Solutions Engineer at Red Hat and my day-to-day work involves OpenShift and Ansible. I'm highly passionate about open source software, cloud, security, and networking technologies.
Plus de résultats similaires
Implementing best practices: Controlled network environment for Ray clusters in Red Hat OpenShift AI 3.0
Friday Five — December 12, 2025 | Red Hat
Technically Speaking | Platform engineering for AI agents
Technically Speaking | Driving healthcare discoveries with AI
Parcourir par canal
Automatisation
Les dernières nouveautés en matière d'automatisation informatique pour les technologies, les équipes et les environnements
Intelligence artificielle
Actualité sur les plateformes qui permettent aux clients d'exécuter des charges de travail d'IA sur tout type d'environnement
Cloud hybride ouvert
Découvrez comment créer un avenir flexible grâce au cloud hybride
Sécurité
Les dernières actualités sur la façon dont nous réduisons les risques dans tous les environnements et technologies
Edge computing
Actualité sur les plateformes qui simplifient les opérations en périphérie
Infrastructure
Les dernières nouveautés sur la plateforme Linux d'entreprise leader au monde
Applications
À l’intérieur de nos solutions aux défis d’application les plus difficiles
Virtualisation
L'avenir de la virtualisation d'entreprise pour vos charges de travail sur site ou sur le cloud