Vim is a text editor I can identify with: Vim and I are both 90's babies, and we prefer to work smarter, not harder. There are a multitude of reasons to learn vim, from its simple navigation tools to its quick and dirty character correction. Here is a crash course in an outstanding tool that every sysadmin should learn.
[ Download now: Vim cheat sheet ]
What is Vim?
The name Vim is an acronym for Vi Improved. This editor is an enhanced version of the Vi text editor that we all know and love, and is normally seen in a CLI form; however, it does have a GUI version available for standard desktop use. Vim allows you to merge files usingvimdiff
—which is not the same as diff
, the comparison utility—as well as an autocomplete feature and a comparison mode that is similar to the diff
utility. This editor's real change and utility is supporting plugins and multiple scripting languages such as Perl and Python. Also included is support for compression functions such as tar
and zip
, as well as network transfer protocols such as SSH, FTP, and HTTP.
Vim's common modes
The Vim editor has three modes that determine how the editor functions: Normal (or Command), Insert, and GUI.
[ Looking for a different text editor? Download the Emacs cheat sheet. ]
Normal mode
Normal mode allows you to give commands to the editor. Functions such as the following can be found here:
:w
to write/save.:q
to quit.:w <filename.txt>
to name a new file.:q!
to quit without saving the changes to the file
Press the Esc key to start the Normal mode and enter :(desired command) [Enter]
to perform your intended task. For example, if I was working in a new file and wanted to name it 'file.txt', I would use the following:
:w file.txt [ENTER]
Insert mode
If you have made it this far, you probably know what the Insert mode does. However, for those who don't, if you press the I key (lowercase i
) once you will see the "INSERT" prompt at the bottom of the screen, indicating that you can now edit or add text.
To exit this mode and return to Normal mode, press the Esc key once.
GUI mode
GUI mode is only available in some environments. It offers a graphical, point-and-click interface to be utilized with a mouse and keyboard.
Vim tips and tricks
Now, imagine Vim being that shady guy on the corner in a trenchcoat selling faux Rolex watches from inside his lapel, only instead of knockoff watches, VIM has tricks and shortcuts on offer. Seriously, there are too many to list in this article, but I will list some of my favorites here:
dd
removes all text from the current line (deleting the full line) and saves the removed text to the clipboard.p
pastes (puts) anything from the Vim clipboard to the current cursor, and pairs nicely with the full line delete shortcut above.r
replaces a character and is great for a quick correction.
Using r
is a bit more complicated than the others:
- Press Esc to enter Normal mode.
- Move the cursor onto the character you wish to correct.
- Type
r
followed by the character that you wish to use.
For example, "Goodbee" can be edited to "Goodbye" by highlighting the first "e" and then entering ry
.
[ Get more out of your text editor: 5 Vim features for power users. ]
Where to start
I encourage you to give these tricks a try. There is no better way to learn than creating a text file and then making random edits.
Actually, that may not be true, which brings me to the absolute best way that I have found to learn Vim. I learn best with a bit of direction, so it's no surprise that a tutor is just what I needed. Vim has a built-in tutor that can be accessed by entering vimtutor
in the terminal. This tutor will give you lessons on specific topics, starting from beginner to advanced. I highly recommend this tool for first-timers.
If you're someone who enjoys having fun with technology, check out the free Vim-based adventure game Vim-Adventures. This game is a great way to learn a new skill while also enjoying some old-school gaming eye candy.
This article is only a small tease of what Vim actually has on offer. Once you are more comfortable with the things we have talked about here, I encourage you to look into "operators and motions" as well as dotfiles for customizing your Vim experience. If you are looking for further info on text editors, check out our other text editor articles.
About the author
Tyler is the Sr. Community Manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. Now that he has surfaced, he lives with his wife and son near Raleigh, where he worked as a data storage engineer before finding his way to the Red Hat team. He has written numerous technical documents, from military procedures to knowledgebase articles and even some training curricula. In his free time, he blends a passion for hiking, climbing, and bushcraft with video games and computer building. He is loves to read and enjoy a scotch or bourbon. Find him on Twitter or on LinkedIn.
Browse by channel
Automation
The latest on IT automation for tech, teams, and environments
Artificial intelligence
Updates on the platforms that free customers to run AI workloads anywhere
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
The latest on how we reduce risks across environments and technologies
Edge computing
Updates on the platforms that simplify operations at the edge
Infrastructure
The latest on the world’s leading enterprise Linux platform
Applications
Inside our solutions to the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech
Products
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud services
- See all products
Tools
- Training and certification
- My account
- Customer support
- Developer resources
- Find a partner
- Red Hat Ecosystem Catalog
- Red Hat value calculator
- Documentation
Try, buy, & sell
Communicate
About Red Hat
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Select a language
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit