What is Vim?
Vim is a text editor designed for use both from a command-line interface and as a standalone application in a graphical user interface.
Why should I use Vim?
One key characteristic of Vim is that you can use it completely and very efficiently without touching your mouse - you can therefore omit the keyboard-to-mouse-motion and vice versa.
This might not seem like a big deal but it really adds up especially if you also start switching tabs and open files with keyboard shortcuts.
Vim is short for Vi IMproved.
vi is a text editor released in 1976 by Bill Joy.
Vim was released in 1991 by Bram Moolenaar and offers additional features - a few of them will be explained in this series.
Another very good reason to learn vi or Vim (on which this series will focus on) is that they are available on a lot of UNIX-like operating systems per default. That means that if you know how to use Vim you already know how you can edit files on many operating systems out there.
But I don't want to use a different IDE!
While it is possible to configure Vim to replace a full-featured IDE I made the experience that that takes a lot of time and is a little bit annoying.
Okay I want to give it a try!
I'm happy to have you on board! First of all you have to decide if you want to try Vim via:
- The CLI
- In which case you can install it on your operating system using your system's package manager (for unix-like os) or with gitforwindows if that is your os
- Your favourite IDE
- In which case you simply have to install the according extension (as mentioned above)
Essential Vim knowledge
Vim can be very intimidating to beginners which is mainly due to the fact that the usage is absolutely not intuitive and that's why many users even struggle to exit the editor.
Therefore I want to mention the most relevant things to know about Vim with descending relevance to get you started.
You can use Vim in multiple different so called modes. The mode you are in determines what action the keystrokes you perform on your keyboard provoke.
You might think that opening, saving and quitting files/Vim is more important than the knowledge of the different modes, Vim provides. But in order to understand how closing Vim works, you need to understand modes.
Here is a quick intro to the two most important modes to get started:
- The default mode you are in when you open a file in Vim is called normal. This mode is used to:
- Navigate within the file (e.g. go to bottom of file)
- Perform manipulations (e.g. delete the line on which the cursor currently sits)
- The other mode is called insert. This mode is used to add and remove text to the file
To switch from normal mode to insert mode, press the
To switch from insert mode to normal mode, press the
open, save and quit
- To open or create a file in/with Vim, type
- To save the changes you performed on the file, (make sure to be in normal mode and then) type
:w(w for write) and then press enter
- To quit Vim, (make sure to be in normal mode and then) type
:q(q for quit) and then press enter. Note: If you performed changes on the file, this command will not let you quit Vim
- To quit without saving, (make sure to be in normal mode and then) type
:q!and then press enter
- To both write and quit Vim, (you probably guessed it) type
:wqand then press enter. There is also another shortcut, which does the same as
:wqENTER: simply press
Ask me questions
I will be happy to answer your questions in the comments section below. Also let me know if you have any tips or ideas for me to improve my post!