Contents

Installing and Configuring Vim

This quick recipe is to install and personalise Vim with themes from Airline. I reckon Vim is a bit hard to learn, but once you know how it works it will empower your hands, also there are tons of command combinations to do cool things.

Installing Vim

The first thing is to install Vim, for that in Debian you can use apt; first update the packages database and then proceed to install the app, as:

1
2
sudo apt update
sudo apt install vim

!!! NOTE: in MacOS it probably is already installed, check with vi --version, if is not, then install with brew install vim.

Now let’s install the plugin manager VIM-plug from the repository junegunn/vim-plug in GitHub, with:

1
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Once VIM-Plug is installed in the autoload directory, edit the ~/.vimrc file (vi ~/.vimrc) and add the following lines:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
call plug#begin('~/.vim/plugged')

Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'

call plug#end()

" This will enable syntax highlighting
syntax on
" This will enable the line numbers on the left
set number

With that we will be asking VIM-Plug to install vim-airline and the themes vim-airline-themes, save the changes and exit Vim (:wq!). Now reopen Vim and type in :PlugInstall and hit Enter, by now both Vim Airline and Vim Airline Themes should be installed.

If you open a file, you should be able to see the status bar with the details of the file, git and location, similar to what you have with powerlevel10k.

The theme installation need some touches and you will need to install the powerline fonts, for that do the follwoing:

1
2
3
4
5
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
cd ..
rm -rf fonts

Finally, edit ~/.vimrc as before and add the following line at the end:

1
let g:airline_powerline_fonts = 1

Now your Vim should look nice and have a nice status bar, but if you prefer you can change the theme using the command :AirlineTheme <theme_name>; if you press the Tab key you can cycle through the available themes or visit the GitHub repository of the theme for details and screenshots https://github.com/vim-airline/vim-airline/wiki/Screenshots.

To make the theme change permanent you can add let g:airline_theme='<theme_name>' to the ~/.vimrc file, for example:

1
let g:airline_theme='powerlineish`

Install and Configure NERDTree plugin

If you need a quick way to browse files and navigate around the file system, you probably will love to have NERDTree. Let’s install it, edit ~/.vimrc and add the following line:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'scrooloose/nerdtree'
call plug#end()
    
let g:airline_powerline_fonts = 1
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

Close and open Vim and run :PlugInstall command as before to install NERDTree

Now NERDTree plugin is installed, to see the directory tree in Vim editor, type in command :NERDTree to launch it.

Colour Scheme (optional)

Some times I don’t want to install Airline themes, but I like to have a dark theme in my Vim, and the colour scheme onedark from joshdick/onedark.vim is the one I use, to install it is super easy, just do the following:

1
2
3
4
5
git clone https://github.com/joshdick/onedark.vim.git ~/onedark
cd ~/onedark
mkdir ~/.vim/colors
cp colors/onedark.vim ~/.vim/colors/
cp autoload/onedark.vim ~/.vim/autoload/

Then edit ~/.vimrc and add the following lines at the end:

1
2
3
4
colorscheme onedark

highlight Normal ctermbg=None
highlight LineNr ctermfg=DarkGrey
Buy me a Coffee
Hope you find this useful, if you have any question please visit my twitter @bigg_blog and if you have a couple of pounds buy me a coffee.
G