How to Use Vim (Customize & Plugins)
Updated Oct 11, 2019
Is learning how to use Vim difficult? Is the learning curve really that steep as many people make it out to be? I'll show you how it is a text editor made with simplicity in mind.
Vim has been perceived by many as a difficult text editor to use.
Unlike any other editor, having to learn Vim at a basic level requires some familiarity with the keybindings to move with.
The Vim keybindings themselves take a bit of time to grasp, but the user will easily edit files after taking the hurdle.
The hurdle itself isn't as enormous as many people make it out to be.
With the right amount of guidance, it won't take too long to overcome Vim for the average user to move forward.
Now let's talk about what makes this minimalistic editor stand out.
What makes Vim special
Similar to emacs, Vim is a lightweight editor that can be used to edit files instantly.
When opening up a file in Vim, the editor presents itself with the bare minimum to begin letting the user edit.
- Files open up instantly.
- A simple cursor to navigate through the file.
- A line counter and percentage indicator to notify the user's current location in the file.
For the experienced individual, this is all that they need to make quick adjustments or to take a look at what's written in the file.
But for someone who accidentally types the Vim command, it will not be intuitive enough to learn how to move or even exit out.
If someone hasn't spent the right amount of time getting used to Vim's way of doing things, it can seem counterintuitive to get simple tasks done.
This leads to many people not furthering their Vim experience, thus, getting bad-mouthed as a constraint to use.
What it's really like
In reality, if one learns and understands one of the few basic keybindings, such as to save, add, exit, or even search, then Vim will start to become very familiar.
Why can't Vim just function like all the others? Won't that make it compete just as well as editors such as VSCode, Atom, etc.?
The thing is, Vim is just different; it just has another way of doing things compared to most editors.
Time spent learning Vim will not be a waste since it can be used across any operating system.
Also, once one understands Vim, they will notice programs that share Vim's keybindings and etiquette.
Can't wait to get the latest tips and tricks?
save the file in Vim
save and exit
exit without saving
If you want to follow along with a walkthrough, then look no further.
Getting started with Vim is pretty straightforward.
Depending on your operating system, it is typically executed by typing out
vim onto the command line.
To begin editing a brand new file on the command line, let's create a simple java program by typing out
You'll be prompted in the command line with the Vim screen like so:
At this point, you may be wondering, "how do I edit the file"?
Don't worry. You've reached the point where most beginners get stuck and cannot move.
To begin editing the text file type, hit
esc, then press
As indicated in the bottom-left corner, you will now enter Insert mode:
Insert mode lets the user start editing the file.
Although there are many options to enter such as command mode, visual mode, and normal mode, I personally just use insert mode the most.
Pressing down with any keystroke will be recorded onto the file.
Let's write out some code to test it out (make sure to move the cursor):
We have written our first code snippet in Vim.
To save these changes on command, it's important to follow these steps:
- Hit the
esckey (disables Insert mode).
- Type out
:wq(write and quit).
- Finally, press
↵(enter) to confirm.
That's all that needs to be done to change and close your saved work on command with Vim.
The rumors spread around the web on how Vim is difficult to move and exit makes me laugh a lot from time to time.
Now, run the code and see if it works:
When I first started to learn using Vim, it was difficult to find something such as this.
Looking back, perhaps watching a video would have saved me the headache.
If you've got the average setup that Vim defaults to, then changing it can make a huge difference to the user experience.
To make changes, we need to edit a special file that is inside the home directly (located by going into the
cd ~ folder).
And that special file is the
Let's start editing it by typing out
vim ~/.vimrc into the terminal.
For the purposes of this tutorial, I'll be editing my dotfile and we'll only be looking at a specific section:
I'll break this down into 4 sections:
- vim-plug automatic installation is a script that installs a Vim plugin manager (this will manage the plugins).
- vim-plug config - start call specifies where the list of plugins starts.
- Plugins are the list of plugins that'll be added (a plugin basically adds more functionality into Vim).
- vim-plug config - end call specifies where the list of plugins ends.
By quickly glancing at the text file, we can easily tell it'll install 4 plugins.
To apply these text changes, just type the
:wq command onto the file, and reopen it with Vim.
You should now be getting some sort of split-screen:
Opening the dotfile will install plugins that we've specified, and store them inside the
Let's just say even if you decide to use my dotfile, you think there's still not enough customizations that'll suit your tastes.
To download more plugins (or themes), go to the VimAwesome website:
They've got a awesome list of one of the most popular Vim plugins to choose from.
I'll be adding a plugin that supports Markdown syntax:
Since we are using the VimPlug plugin manager, let's follow the appropriate instructions to get it installed.
1. Insert the vim-markdown code into the dotfile:
2. Run the following commands in order:
After that, the vim-markdown plugin is all set!
If you want to keep adding more plugins, just repeat the 2 steps (with a different plugin of course) and they'll be installed in a snap.
Hopefully, using Vim commands will feel like second-nature!
After memorizing the keybindings up above, it will be enough to take advantage of the sheer amount of capabilities of what text editing can do.
Plus, you don't have to settle for the default theme.
Change it up a bit and you'll see what I mean.
It can replicate any other editor's theme that's out there and still use the same set of commands.
If you miss your previous editor but find Vim's keybindings hard to let go, then incorporating it is your best bet.
Its portability is simply unmatched!
Have any questions? Leave a comment down below.