Siraphob Kan
Posted on December 21, 2021
TLDR; My dot-file can be downloaded from this link.
Prologue
Vim was invented around 30 years ago (1991). It is a text editor that runs in a terminal. Programmers at the time use Vim to write their code.
In mordern days, even with new text editor like VSCode, intellij, sublime text, etc; Vim still stand tall among them. This is because Vim has some advantages over those text editors.
Vim is extremely lightweight.
Vim itself is very small and it's likely shipped with most Linux distros. The only dependency it needs is a terminal.People who use Vim could edit their code faster.
Vim enables full keyboard control. You can navigate, edit, delete, replace, etc. using only your keyboard. You'll seldomly need to touch your mouse when writing code ever again.Vim is highly customizable.
You can configure Vim to work in your way. Keybindings are not intuitively enough? You can remap it! Want to add Git integration? You can do that too! Add code-completiong and linting for your programming language? I don't need to say that it's achievable too.
Why Neovim?
You may wonder why I was talking about Vim when the title said Neovim. Well, here I am. In this article I'm going to explain why we'll use Neovim instead of Vim.
What is Neovim?
Neovim is a forked version of Vim. It's basically Vim but driven by an open-source community. On the other hand, Vim is maintained by only one person which is its original author, Bram Moolenaar.
Why should you use Neovim instead of Vim?
As I said, Neovim is maintained by the community. And because of that, the tends software evolves faster and more compatible with the modern system. And by that term, I am talking about integration with other third-parties and bug fixes.
Moreover, Neovim's software architecture was redesigned to be more extensible and could process task in multi-thread fashion.
With all that; the traits of its predecessor, blazingly fast software, and powerful plugins; is the reason I recommend you to use Neovim over regular Vim.
Installing Neovim
If you're on Debain-based system, you could run the following command.
sudo apt-get install neovim
For other distributions/system, please refer to this wiki page.
After the installation completed, you could start Neovim by just typing neovim
in your terminal.
Configuring Neovim
Before any processes of Vim begins, Vim will read its configuration file first.
So does Neovim. Neovim's configuration file is located at $HOME/.config/nvim/init.vim
. If your system doesn't have this directory, you could create one.
The init.vim
file allows you to specify how Neovim should behave. The look
and feel, keybindings, and plugins are all configured through this file.
Installing plugins using Vim-Plug
A way to install plugins in Neovim is through a plugin manager. There exists many plugin managers for you to choose. Here is some examples; Vim-Plug, Pathogen, Vundle, etc. In this article, I'm going to use Vim-Plug since it's very easy to use and setup.
To install Vim-Plug for Neovim, please run the following command.
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
Neovim configuration file
After the installation completed, open init.vim
and add the following snippet.
call plug#begin('~/.config/nvim/plugged')
" This is where you define your plugins.
call plug#end()
The snippet above make Vim-Plug scans for the defined plugins. Any defined plugins that don't exist in nvim/plugged
directory will be download and install. To trigger the Vim-Plug installation, reload Neovim and type :PlugInstall
.
Protips: If you're editing
init.vim
, save the file by running:w
and then:source %
to source the current file. After that you can callPlugInstall
without needing to reload the Neovim process again.
Finding plugins
You can find any plugins for Vim on Vimawesome. When you select a plugin on Vimawesome, it'll show installation instruction for
any plugin manager.
For example, please see Fugitive.
Useful plugins I recommend.
I am going to list all the plugins I use and explain what they do in my Neovim configuration. The list is shown below.
NERDTree - File browsing
Plug 'scrooloose/nerdtree'NERDTree Git Plugin - Git integration for NERDTree
Plug 'Xuyuanp/nerdtree-git-plugin'Vim Devicons - Extend Vim to use beatiful icons
Plug 'ryanoasis/vim-devicons'Syntastic - Syntax Checking
Plug 'scrooloose/syntastic'Gitgutter - Show git diff in a file
Plug 'airblade/vim-gitgutter'NERDCommenter - Add comment keybindings support
Plug 'scrooloose/nerdcommenter'Vim Surround - Brackets wrapping
Plug 'tpope/vim-surround'CTRL-P - File search
Plug 'ctrlpvim/ctrlp.vim'Vim-Go - Go programming language support for Vim
Plug 'fatih/vim-go'COC(Conquer Of Completion) - Syntax completion support
Plug 'neoclide/coc.nvim', {'branch': 'release'}Colorschemes - Customize Vim colorscheme
Plug 'flazz/vim-colorschemes'Vim-Javascript - Javascript support
Plug 'pangloss/vim-javascript'Vim-Graphql - Graphql Sytax highlighting
Plug 'jparise/vim-graphql'Indentline - Show indentation guide in Vim
Plug 'yggdroot/indentline'FZF - FuzzyFinder support for Vim
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'Fugitive - Git integration
Plug 'tpope/vim-fugitive'Vim-Airline - Vim status bar customization
Plug 'vim-airline/vim-airline'Undotree - Undo history
Plug 'mbbill/undotree'
My dot-file
For anyone who's looking for my dot-file. You can download it from this link.
Closing thoughts
In my opinion Neovim is not the thing that every developers should adopt. It is also not something that would instantly replace your current text editor. Honestly, I think the best text editor is not the fastest one or the one with the most plugins. The best text editor is the one that suits your workflow the most.
Neovim is one of those text editor that fits my workflow. It is fast, lightweight, and highly customizable. It is a little bit harder to learn at first because of its steep learning curve. But I assure you that it is worth learning and it will pay off a great prize!
Posted on December 21, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.