Vim

Vim is a command line text editor.

Config

!!! Commands and configuration you want loaded by default can be put into a file called ~/.vimrc.

For example, to show line numbers you could:

echo ":set number" >> ~/.vimrc

Basics

Editing

After opening vim, to edit press i. To cancel out of editing mode, press esc. If you aren't in editing mode, the commands explained below will work.

How do I quit vim?!

Normally, you would do:

:q

You may wish to write, then quit:

:wq

You may also wish to force quit:

:wq!

Search and Replace

%s/find string/replace string/g

Search

Ensure you are not in editing mode, then type / followed by your search string. Use n to go to the next match, and N to go to the previous match.

/find_this

Edit multiple files

If you open multiple files (for example vim *go), you can go to the next file using :n.

Generally, you would want to write, then go to next file:

:wn

Show line numbers

:set number

Spell Check

First, run the following (or put into your .vimrc file);

:set spelllang=en
:set spellfile=~/.vim/spell/en.utf-8.add

Then, to use spellcheck run:

:setlocal spell

Now, to view word suggestions, when hovering over a word try z= and follow the prompts.

To navigate between misspelt words, use ]s and [s.


Checkout our Web Scraping Service