Vim quick start

Go to: Why you should consider using Vim? · I started Vi and nothing works · Navigation · Reading terminal output · Working with multiple files and windows · Single repeats · Compare upstream and edited version of file in split · Macro · .vimrc

Why you should consider using Vim?

Normally nobody cares about the tools you use for development. I don’t either, but for some reason you visited this page. So I present you the benefits of using Vim (compared to your favourite IDE™):

If you care about the things above (and you have all the time in the world), Vim might be for you.

the Unix philosophy “is the idea that the power of a system comes more from the relationships among programs than from the programs themselves.”

Now some opinion: Most of those fancy IDE features are done by language servers. Autocomplete is overrated, it’s the automations that will save you time.

Here is a good article on the history of Vim.

I started Vi and nothing works

help compatible
set nocompatible

The excellent vimtutor is a good starting point. Tells you how to navigate within a file, switch modes and do some basic editing tasks.

My favourites:

Insert mode

^H: Backspace
^W: Delete word
^U: Delete line

Reading terminal output

ls -ail | vim -

Now check how we can use the % command-line range specifier.

:help :%

You can also use Linux commands to modify buffer content.

sort; grep; cut

Don’t forget to trim before cut!

Now insert the date in the current line.

:help :.

:.!date

Do the json lookup

https://pokeapi.co

Working with multiple files and windows

Do some buffer magic here: bn, bp, ls, bd

save layout: :mksession then start with vim -S

Single repeats

Simple changes can be repeated with the . command.

Global search and replace? Nah, search and repeat with dot.

Multiple repeats

Keep lines that contain string

:v/keeeep/d

Compare upstream and edited version of file in split

:% !git show main:my-file.txt

Then reload file that was edited outside of vim

Macro

q as in quote?

GDB???

Yes pls.

Termdebug

Quickfix

:e $VIMRUNTIME/compiler/<Tab>

My .vimrc

I try to live without plugins, but:

Read more

Happy editing!

#productivity #training