[~] BACK



~~ VIM (I) ~~

** BASICS **

[VIM] | [20211203] | [0] | [0x17]




It had to happen. Vim had to appear here at some point and since Vim just turned 30 years old, it justifies it all the more.
I thought we'd just start a little series in which I (try to) explain what Vim is and how it is used.
The good thing is that I'll learn a lot in the process. :D
If you want to have all the parts together in a clear way, use [VIM] as a sorting system.
This first part will first of all be about what Vim is, where Vim comes from and how it is used in general.
The later parts of the series will then go into more detail about use, configuration and modification.
So let's start with the (in my opinion) best editor there is.

WHAT IS VIM

Vim is basically a text editor and is based on "vi" and stands for "Vi IMproved". However, it is not a simple one like Notepad, but a highly customizable and expandable editor.
Vim can be used to edit simple files (the NERDBUDE HTML files are edited completely in Vim), create local wikis for your own structuring, read RSS feeds and much, much more.
Vim is available for almost every operating system and is usually even pre-installed.
Vim was developed by Bram Moolenar and released on November 2nd, 1991.
Vim was originally developed for the terminal, but now also offers a GUI version with extended mouse support - but that's not what we're here for. I'll stick with the terminal version. That's all the history - let's get started with Vim.

Vim can do everything you find in modern editors and IDEs:

Syntaxhighlighting
Linenumbers
Diff Checks
Git support
Colorscheming
Markdownsupport
Filemanagment


Not all of these functions are available from the start, but must be loaded via a plugin.

START VIM

To start Vim, simply type:

TERMINAL
vim


When Vim is started for the first time, you will see the following start screen:



To dispel the myth that it would be difficult to close Vim again - it even says on the start screen how to close Vim again:

TERMINAL
:q


So if you type ":" and "q" and confirm with ENTER, Vim will disappear again.
Now we want to use Vim and not quit straight away.
So open Vim again and start typing. Not much happens though.
Why is that? Very simple. Vim basically has 3 different modes in which it can be operated. The individual modes are activated by simply pressing a key:

I   - Insert Mode
V   - Visual Mode
ESC - Normal Mode


The modes are relatively self-explanatory.
In INSERT mode, things are inserted, i.e. written. In VISUAL mode, the contents of the file are manipulated or changed, and NORMAL mode offers the option of using commands, copying and pasting text, and various other options.

The only special feature here is VISUAL mode. It can be used in three different ways:

  v  - Character Mode
  V   - Line Mode
  CTRL + v   - Block Mode


I will explain exactly how VISUAL mode works in a later part.


NAVIGATION

Vim can be controlled using the cursor keys and also using "HJKL". This type of control dates back to the "vi" era and can be traced back to the computer on which "vi" was developed. It was an ADM-3A terminal without cursor keys as is common today, but with cursor arrows on the HJKL.
The switch from the cursor keys to HJKL takes a little time, but once it's in your muscle memory, it's much more pleasant. There are also various tools that are also coded with the "Vim Keys" or plugins that make current tools usable with the "Vim Keys".

PRACTICE

At the end of this series there will always be a small example. This time open Vim, activate Insert Mode, save and close.

$ vim htp.md (opens vim with a file called htp.md)
I (activates insert mode)
Hack the Planet! (text that should be in the file)
ESC (back to normal mode)
:w (saves the changes)
:q (closes Vim)

[~] BACK