It's fast, free, open-source, basically installed everywhere, you can customize it however you want and you look swish with using terminal (remember Matrix?).
9/10 if you'll SSH into a server you'll have to use VIM so why not to learn it and use it daily?
Movement in VIM happens a bit differently. Basic movement:
h
- move leftj
- move downk
- move upl
- move right
Of course you can use arrow keys, but the biggest benefit in using hjkl
is that your hands doesn't have to move from the middle low on keyboard. Speed is key!
VIM has three different modes:
- Normal - where you move around, paste, etc
- Insert - where you type
- Visual - where you highlight stuff, copy, etc
You might think that this is increasing the difficulty of using VIM but in reality, this helps you to work faster.
Normal mode is the one you start with.
Insert is where you type. Access by typing i
to start typing from the current cursor placement.
Visual allows you to highlight stuff and do something with it. Access by typing v
.
Command line allows you to use commands (inside and outside VIM). Access by typing :
.
To exit from any mode to Normal mode, use esc
.
Also, remember one thing - leave insert mode when you've finished typing. VIM promotes editing first approach, rather than writing first approach found in VS Code and similar.
A lot of memes here, but it's simple:
:q
to quit.
:w
to save.
:wq
to save and quit.
How to move around faster:
w
- move to the beginning of the next worde
- move to the end of the next wordb
- move to the beginning of the previous word0
- move to the beginning of the line$
- move to the end of the linegg
- move to the top of the fileG
- move to the bottom of the file}
- move to the next paragraph{
- move to the previous paragraph
Most of the commands takes a number in front of it, so - f.e. to move to line 50 in this file, use :50
or to move 10 lines up, use 10k
Also, you can invoke insert mode faster:
a
- start insert after current characterA
- start insert at the end of the current lineI
- start insert at the beginning of the current lineo
- start insert below the current lineO
- start insert above the current line
y
- Copy (in visual mode)yy
- Copy the whole line (in normal mode)p
- Paste the line (in normal mode)P
- Paste the line above current line (in normal mode)dd
- Delete whole line (in normal mode, available to paste, so it's basically copy and delete)
So, if you start using VIM, the barebones version might be VERY unappealing. What to do to make it nicer?
In the root (~
) of your system, create (or open) a file called .vimrc
. This is how VIM will understand what to load prior to the usage.
Bear in mind, some plugins will negatively impact startup time so YMMV
What I think is the good starting point:
" Show where you are
set number
" Show the ruler on left hand side
set ruler
" If you're still scared about not using mouse
set mouse
" Performance boost when using macros
set lazyredraw
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs
set smarttab
" 1 tab == 2 spaces
set shiftwidth=2
set tabstop=2
" Linebreak on 500 characters
set lbr
set tw=500
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
First thing would be using :help <command-name>
with anything you're doing. The manual in VIM is immensely helpful.
Second, run vimtutor
daily. One month of running it, everyday, before work and you're golden.
If you like books, there's one called Practical Vim - really good one, shows a lot of tricks.
If you like youtube, there's more than one channel you can watch to expand your VIM horizons (f.e. Primagen).