Table of contents
A table of contents of this series can be found here.
What is vim?
vim is a cli-based text editor which means that it is a software you can use on the command line to edit textfiles.
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-hand-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 cli 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 (almost) every single UNIX-like operating system per default. That means that if you know how to use vim you already know how you can edit files on almost every single operating system 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 for write) and then press enter
To quit vim, (make sure to be in normal mode and then) type
(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
and then press enter
To both write and quit vim, (you probably guessed it) type
and then press enter. There is also another shortcut, which does the same as
:wqENTER: simply press
Thanks to Peter DeChamp Richardson for pointing out that the
:wq option was missing.
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!
Here is the second part of this series: A brief introduction to vim 2/9