Discovery of Vi and Vim Editors: Users Best Friends in Linux
Table of contents
Introduction
Imagine you have a magic wand that lets you edit text in a super cool and powerful way. Well, that's kind of what Vi and Vim editors are! They are special tools that help you modify text files, like documents or code, using commands in a fancy computer command-line environment.
These editors have been around for a really long time and have become legendary among tech-savvy folks. They may look a little tricky at first, but once you get the hang of them, they can make your text editing tasks super easy and efficient.
So, let's embark on an exciting journey to discover the magic of Vi and Vim editors and how they can transform the way you work with text on your computer!
Vi Editor
Vi, short for "visual," was introduced in the early 1970s, making it one of the oldest text editors still in active use. Its minimalistic interface might appear daunting at first, but once you grasp the basics, you'll find it incredibly efficient.
Imagine you want to edit a file called "example.txt." Simply open your terminal and type:
[root@192 Desktop]# vi example.txt
Voila! You're now in Vi's command mode. To start editing, press the 'i' key for insert mode, and you can begin typing your content. Pressing the 'Esc' key takes you back to command mode, where you can execute various commands or navigate through your text.
Vim Editor
Vim, short for "Vi Improved," which took the foundation of Vi and expanded upon it with a wealth of additional features and extensive customization capabilities. Vim retains all the commands and modes of Vi while incorporating powerful enhancements.
To open a file using Vim, enter the following command:
[root@192 Desktop]# vim example.txt
You can easily personalize your Vim experience by customizing your .vimrc
file, where you can define key mappings, color schemes, and much more.
How to Vi/ Vim?
Editors work on three modes:
Insert Mode
Command Mode
Execution Mode
Vi and Vim may seem intimidating at first, but mastering them can turn you into a command-line wizard. Here are a few essential commands to get you started:
Delete Operation:
dd
- To delete entire line5dd
- To delete entire 5 lines at oneD
- To delete a line after the cursor5D
- To delete 5 lines after the cursor
Saving and Quitting:
To save changes and exit Vim, use the command
:wq
.To quit without saving, type
:q!
.
Searching:
Press the
'/'
key followed by your search query to find text within the file.Use
'n'
to jump to the next occurrence.
Copy, Cut, and Paste:
yy
- To Copy content from a line5yy
- To Copy next five lines from the position on cursotp
- To Paste the content you copied earlier
Screen Navigation:
H - Head of the screen
M - Middle of the screen
L - Bottom of the Screen
Display Lines: :
set su
- To Display the line number in the editorset nonu
- To remove the line number
Search and Replace operations:
%s/<old-word> /<new-word>
- To replace a single old word with new word%s/<old-word> /<new-word>/g
- To replace new word on all Places
Read one file in another
:r <filename>
- To read on file in another file
Conclusion
Vi and Vim may seem like relics from the past, but they remain essential tools for many Linux enthusiasts. Their speed, efficiency, and extensibility have earned them a dedicated fan base. So, if you're willing to invest some time in mastering these editors, you'll be rewarded with unparalleled control over your text editing workflow. Embrace the command line and let Vi and Vim empower you to new heights!
So, go ahead and dive into the world of Vi and Vim. Your fingers will soon be dancing across the keyboard, effortlessly manipulating text with the grace of a seasoned pro!
Subscribe to my newsletter
Read articles from Shubham gour directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Shubham gour
Shubham gour
Release Management Professional | Transitioning to DevOps With a proven track record in Release Management, I'm on an exciting journey to transition into the world of DevOps. I specialize in orchestrating the smooth deployment of software and applications, and I'm now gearing up to bridge the gap between development and operations. My passion lies in optimizing release processes, automating deployments, and ensuring the efficiency of IT operations. I'm actively enhancing my skill set in DevOps practices, including cloud technologies, scripting, and CI/CD pipelines. I'm keen to connect with professionals who share this enthusiasm and explore opportunities for mutual growth and collaboration in the DevOps domain. Let's connect and exchange insights about the evolving landscapes of Release Management and DevOps! #ReleaseManagement #DevOps #EfficiencyOptimization