Vim Setup & Customization (with vim-plug)
1) Install Git
Use your OS package manager:
| sudo apt update && sudo apt install -y git
|
2) Install vim-plug (plugin manager)
| curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
3) Create/Customize ~/.vimrc
Paste the following into ~/.vimrc:
| " Section Start:
call plug#begin()
Plug 'preservim/nerdtree'
Plug 'vim-airline/vim-airline'
Plug 'flazz/vim-colorschemes'
call plug#end()
set encoding=UTF-8
" Add Completion and navigation when interacting with vim:
set wildmenu
" When a bracket is inserted, briefly jump to the matching one.
set showmatch
" While typing a search command, show where the pattern , as it was typed so far, matches. The matched string is highlighted.
set incsearch
" When there is a previous search pattern, highlight all its matches.
" When tired of highlighing: :nohlsearch
set hlsearch
" Always set nocompatible...
set nocompatible
" Better to set line number:
set number
" Add statusline:
" gives you:
" n: file number
" F: file location
" m: file modified ?
" r: Readonly flag, text is "[RO]".
" y: Type of file in the buffer, e.g., "[vim]".
" =: Separation point between left and right aligned items.
" l: Line number.
" L: Number of lines in buffer.
" c: Column number (byte index).
" V: Virtual column number as -{num}.
" P: Percentage through file of displayed window.
set statusline=%<\ %n:%F\ %m%r%y%=%-35.(line:\ %l\ of\ %L,\ col:\ %c%V\ (%P)%)
" Tell when the last window also has a status line:
"'laststatus' = 0 never a status line
"'laststatus' = 1 status line if there is more than one window
"'laststatus' = 2 always a status line
set laststatus=2
" show tab line even if no tab:
set showtabline=2
" Use case insensitive search, except when using capital letters
set ignorecase
set smartcase
" Indentation settings for using 4 spaces instead of tabs.
" Do not change 'tabstop' from its default value of 8 with this setup.
set shiftwidth=2
set softtabstop=2
set expandtab
|
4) Install & Update Plugins in Vim
Open Vim.
Install plugins:
Update plugins later:
That’s it—Vim is set up with NERDTree, Airline, and a colorscheme pack, plus sensible search, UI, and indentation settings.