If you’re like many people, you know Vim as an editor that you open to adjust the configuration file, so you can’t control the exit. On the other hand, if you use Vim frequently, you know how effective its modal editing features are. If you use Linux or another Unix flavor, Vim is worth learning.
Nevertheless, Vim shows age quite easily. By default, it lacks many of the features we’ve come to rely on in modern text editors. Install a few packages and Vim can keep up with Visual Studio code, Sublime text, and more.
Plugin Management: Vim-Plug
One key feature in modern text editors is the ability to extend them with extensions. Although Vim added native package management in version 8.0, many find it awkward compared to third-party package management. One of the most popular package management programs is Vim-Plug.
Before you can start using the Vim Plugin, you need to install it. To run the next terminal on a Unix system such as Linux or macOS, download and install the vim plug-in.
curl -fLo ~/.vim/autoload/plug.vim --create-dirs
If you are using Vim in Windows, you can install Vim-Plug by attaching the following information to PowerShell.
$uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
Now you can install extensions by adding them to your own
file. You need to add two new lines to the file:
Add to install plug-in
, followed by the next part of its GitHub URL
in individual quotation marks. For example, to install the Solarized color scheme, your configuration file contains the following:
For more information on installing Package Manager, see Vim-Plug GitHub page.
Error checking: Synthetic
Another feature that many have come to trust is the editor you choose, which tells you when the code you enter is incorrect. This is often called “fluff.” It doesn’t stop you from writing code that doesn’t work, but it does catch up with basic syntax errors you may not have noticed.
As the name suggests, Syntastic is an extension of Vim’s syntax checking. It doesn’t actually do much on its own for many languages. Instead, you need to install a filter test or syntax checker for the language or languages you selected. Syntastic then integrates the scanner with Vim and scans your code every time you save the file.
Syntastic supports more languages than we can list here, so it is very likely that the language you are using will be supported. For instructions on configuring the plug-in, see Synthetic GitHub page.
Completing the code: YouCompleteMe
The syntax checker is nice, but if you come from Visual Studio code or a similar feature pack editor, something else is probably missing. This is a code contest, also known as Intellinense in the Visual Studio world. If you use frills over edit configuration files, it makes your life a lot easier.
Finishing the code makes it easier to write the code by opening suggestions as you type. This is nice if you use a method that is heavily nested so you don’t have to remember the whole string.
YouCompleteMe is a code completion engine for Vimille and is one of the most powerful plugins you can install. It is also a little trickier to install than other extensions. You can install the basics with a package manager like Vim-Plug, but you have to compile it.
The easiest way to compile the plugin is to use the included one
manuscript. To do this on macOS or Linux, type the following:
Note that on Linux, you must install the development tools, CMake, and required titles before you can compile YouCompleteMe.
For instructions on installing and compiling YouCompleteMe on other systems, or for more information, see this article YouCompleteMe GitHub page.
Fuzzy search: CtrlP
If you are working on a project with several different files, Vim’s method of opening the files may frustrate you.
command has autocomplete, but you still need to know where your files are located. You could drop on the command line to find it, but wouldn’t it be better if you could do this directly from Vim?
Fortunately, you can. The CtrlP extension can search for files, but it can also do much more. CtrlP GitHub page describes it as “full path fuzzy file, buffer, mru, tag, … Vim finder”. The plugin is similar to Sublime Text’s “Goto Anything” command, which has a surprise surprise: Ctrl + P or Command + P.
This feature or similar can be found in most modern text editors, and if you find it missing, it’s nice to be in Vim.
File Browsing: NERDTree
You prefer more traditional file browsing. If you need a left-hand panel display of files found in many vendors, you’ll be glad to know it’s available in Vim. This is thank you NERDTree extension.
Unlike the left menu for Sublime Text, Visual Studio Code, and others, NERDTree is an exploration of the entire file system. Instead of just showing the project directory, you can navigate anywhere on your computer. If you are working with files on multiple projects, this can be a very handy feature.
Open in NERDTree Vim only
command. If you prefer to bind it to a command, you can do it with a
option such as the following:
This allows you to simply press Ctrl + N to open and close the NERDTree panel.
Git integration: escape.vim
Git integration has become a mandatory feature in modern text editors, so it’s good to know that it’s also available in Vim. The GitHub project page describes the fugitive.vim file as “such an awesome Git wrapper that it should be illegal”.
bring something similar to what you would have seen
command. If you have finished processing the file and are ready to commit to it, run
. This will allow you to edit the engagement message in the currently running Vim window.
There are too many commands to list here, and you can run any standard Git command by running
. See the page for more information, including screens fugitive.vim GitHub page.
Looking for even more Vim tips?
The tips above will help you modernize Vim, but they’re not the only thing you can do to customize your editor to your liking. As you may have already guessed from reading this article, Vim is a very adaptable editor.
If you’re ready for more, check out our catalog Vim adjustments to make it even better.
Finding useful websites is difficult. There are literally billions of them. Some are useful, some, not so much. Some of the useful websites are quite popular, and rightly so — a tool like Canva has a life …
About the author