What Vim Is and Why You Should Learn It

Contents

keyboard_tab

The course is part of this learning path

Vim Masterclass
11
6
3
Start course
Overview
Difficulty
Beginner
Duration
12m
Students
104
Ratings
4.5/5
starstarstarstarstar-half
Description

This course introduces the Vim Masterclass learning path, explains the course downloads available with it, and provides an overview of what Vim is and why you should use it.

Transcript

VIM is an advanced text editor. The name VIM is a contraction of Vi and IMproved. So VIM is Vi IMproved. Now I'm not going to bore you with an entire history lesson but quickly Vi is a text editor that was originally created for the Unix Operating System. Vi is actually short for visual and started out as the visual mode for the even older EX line editor. Now on most modern systems, VIM has replaced a Vi. Even if you think you're starting Vi by running the Vi command, for example VIM is what actually starts. So long story short VIM is a powerful text editor as you can probably guess I'm a huge fan of VIM. I've used it almost every single day since the late 1990s. Now I would like to take the next few minutes and share with you why I absolutely love VIM and why it's worth your time to learn how to use VIM as well. For starters, VIM is installed practically everywhere. I can't remember ever logging into a system and not being able to use the VIM editor. Most Linux distributions install it by default with other editors such as Nano or Emacs they may or may not be available. If you're working on a system and your only editor choice is VIM, then you need to at least be able to use it to make simple edits. Also many programs rely on an external editor by default that external editor is VIM in most cases, typically this can be overwritten by setting an environment variable such as editor. However, if you execute one of these commands and find yourself looking at the VIM editor, you will be happy you at least know how to make some simple edits and how to exit out of VIM. Just a couple of commands that rely on external editors such as VIM include Crontab, VIsudo and GHET. VIM is amazingly powerful. If you're used to using Nano then you're going to be blown away when you start learning just some of the most basic features available to you in VIM there really is no comparison. Once you start learning VIM you'll be more efficient and effective than you ever were when nano. All the power VIM provides allows you to do things quickly. You can even make some complex edits fairly quickly and easily. Once you know how VIM works. Just some of the powerful features include macros, registers, command repetition, auto-completion, text object searching filters and global substitution. When you learn how to navigate within VIM you'll find that you can use those same navigation key bindings and other programs such as man and less. You can even configure your command line shell to use VIM style line editing features. For example, I use set space dash o space Vi for my bash shell. So I can use VIM key bindings to browse my command history and even edit the current command line. Even outside a command line environment you can put your VIM knowledge to use. For example, if you have Gmail keyboard shortcuts enabled you'll find yourself using VIM commands right in Gmail even other editors support VIM modes. Sometimes the mode is built in and other times you'll need to install a plugin first, here are just a few editors where you can put your VIM knowledge to use. They include Adam, Eclipse, Abby word, Kate, sublime text, notepad plus plus X code in many more. Keeping with a knowledge transfer theme VIM is available on a number of different operating systems. VIM is available on Linux, Unix, Mac, Open VMs and Windows. Let's say you want to learn VIM because use Linux at work all day. But when you get home, you love to use your Mac. Well, that's no problem. Simply install VIM on your Mac system. And you can use the exact same text editor at work and at home. And honestly, once you learn how to really use VIM you'll want to use it everywhere. Not only can you run VIM from the command line and use its textual user interface you can run VIM in a graphical user interface mode suitable for graphical environments. The graphical user interface mode of VIM has all the same features, you know and love in VIM, in addition to features that you would expect from a graphical application those additional features include things like scroll bars, menus, a list of recently open files the ability to use a mouse and integration with a system clipboard, contrary to what some people might think syntax highlighting is more than just making your files look pretty. The most important thing about syntax highlighting for me is that it makes mistakes easy to spot. If you make an edit to a file and then the syntax highlighting disappears for that line take that as a sign you need to check your work. By the way, VIM includes syntax highlighting for more than just programming languages. If you're a Linux system administrator then syntax highlighting for the C programming language might not be as useful to you as syntax highlighting for configuration files by default VIM includes syntax highlighting for Apache configuration files, deny hosts files get config files, grub config files, eldap.com login defs, named D and bind configuration files Pam files, Squid Configuration Files SSH configuration files, and Sudoers just to name a few, if there isn't syntax highlighting available by default for a certain file type you find yourself working with often. You can many times find plugins that provide such highlighting. For example, if you use Ansible for configuration management, you can install an Ansible configuration file syntax highlighting plugin. Even if you're not making changes to scripts source code or configuration files having syntax highlighting improves readability it can make files easier to scan. Many VIM Commands can easily be recalled using simple mnemonics. In my opinion, VIM commands like I for insert, D for delete, and Q for quit are a lot easier to remember the commands like F six or control alt shift F that other editors use. VIM is like a language. Once you start to think in VIM, you'll be able to easily start stringing together commands just like you would string together words in a sentence before you can speak you don't have to memorize every possible sentence. Nope. You just use sentence structures and plug in the appropriate words. Like language VIM has the concept of verbs, nouns, or objects and adjectives. For example, to delete a word you type the command DW which is an action and an object. If you want to perform a different action on that object then use a different action command. For example, to change the text of a word you would use CW. To delete everything contained within a pair of quotes, You can use the command DI quotation mark. This means delete inside the quotes. You have an action, which is delete an adjective inside and an object quotation marks. If you want to delete three words, for example you use the command D three W which literally means to delete three words. It's very language like there's no need to get hung up on any of these commands at this point, the idea here is just to demonstrate how easy it can be to think in VIM and how it's actually more efficient than manually learning dozens and dozens of commands for every little situation that you might encounter. Trust me that I get it. Reading dry technical documentation is boring. However, once you have a little exposure to VIM, VIM's built in help system comes in really handy. You can use it to quickly look up command syntax and more all without leaving the editor. You can even edit your file while referring to the documentation all on the same screen, the documentation that comes with VIM is very well written and easy to use. I love using VIM. And once you get the hang of it you're going to love it too. With VIM, there is usually more than one way to accomplish the same task. So it can be fun to use your creativity when making edits you can even make a game out of it by thinking how you can accomplish a given task with the fewest amount of keystrokes. Even if you're not intentionally trying to make VIM fun it can really be a joy to use. One of the main reasons I love VIM is because it's so powerful and efficient getting some serious work done quickly is usually enough fun for me.

About the Author
Avatar
Jason Cannon
Founder, Linux Training Academy
Students
3386
Courses
60
Learning Paths
8

Jason is the founder of the Linux Training Academy as well as the author of "Linux for Beginners" and "Command Line Kung Fu." He has over 20 years of professional Linux experience, having worked for industry leaders such as Hewlett-Packard, Xerox, UPS, FireEye, and Amazon.com. Nothing gives him more satisfaction than knowing he has helped thousands of IT professionals level up their careers through his many books and courses.