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.
저자 소개
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.
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
가상화
온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래