The init.vim file
By the way, this is part of a huge collection of notes and flashcards called CodingNotes. Check it out here https://www.codingnotes.io/ .
CodingNotes is also on Product Hunt today so consider giving it an upvote CodingNotes β Notes and flashcards for various programming languages (producthunt.com)
With the
init.vim
file, you can customize how Vim / Neovim looks. You can set generel values on how the editor behaves and install plugins ( e.g. colorschemes, syntax highlighting etc.)
The file
π‘ It is located under ~/.config/nvim/init.vim
( ~ means the home directory). Change onto this directory w. cd ~/.config/nvim/init.vim
.
π‘ Sometimes, you also have to create the file at first. Write cd ~/.config/nvim
and write touch nvim.init
. This will create the file.
Structure of the file
Start section
π‘ Here, you set parameters of how Vim looks like or behaves.
β For example , set number
means that we want line numbers. The init.vim
file saves this configuration and will display line numbers at the next reload.
β If you just want line numbers for this one session, hit :set number
when you are in normal mode. You will have line numbers but they are not part of the init.vim
file so they will only appear for this session ( when you have closed vim and reopen vim, they are not there anymore )
Typical configuration
:set number:set autoindent:set tabs top=4:set shiftwidth=4:set smarttab 6:set softtabstop=4:set mouse=a
Plug section
π‘ Here, you install your plugins. These are typical from Github , so the syntax for installing is Plug 'url'
π‘ You have to start this section w. call plug#begin()
and end it w. call plug#end()
Install
π‘ If you want to install a plugin , we at first need a tool that lets us install plugins. We will use vimplug.
β in order to install vimplug, you must also install curl if you have not ( it is heavily used to transfer data)
sudo apt install curl
β then, you can install vimplug ( from the github repo, scroll down and find the command for vim or neovim)
GitHub β junegunn/vim-plug: Minimalist Vim Plugin Manager
β for this, you will also need git ( sudo apt install git if you have not installed it yet)
Then , be in normal mode and hit
:PlugInstall
. This will install the plugin. Relaunch Neovim and you will see the airline.
Advanced section
π‘ This section is for the configuration of the plugins you installed as well as general but advanced settings. I will make a dedicated blog post on this as it is ( like the name suggests) fairly advanced.
By the way, this is part of a huge collection of notes and flashcards called CodingNotes. Check it out here https://www.codingnotes.io/ .
CodingNotes is also on Product Hunt today so consider giving it an upvote CodingNotes β Notes and flashcards for various programming languages (producthunt.com)
Hope you learned something !