loading...

I spent 3 years configuring (n)Vim and this what I learnt

christalib profile image chris ・5 min read

TL;DR: just get me the plugins

(I use neovim so some plugins might not entirely work for vim)

You can check my full configuration here. I did not mention mappings because I think this is very personal and changes from one person to another. I only take care of plugins in this article.

the essentials

If you use vim-plug as a plugin manager, just put those in your .vimrc or your init.vim if you are using neovim.

  • Plug 'dense-analysis/ale' : Ale is a very powerful linter and fixer that works with many programming languages, a real must have (especially because it work almost out of the box) link!
  • Plug 'Shougo/deoplete.vim' : deoplete is a completion tool that work especially well with neovim but you can find other completion tools such as CoC. You can also add deoplete with specific languages, here with jedi for Python, deoplete-go for Go and solargraph for Ruby:
    if has('nvim')
      Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
    else
      Plug 'Shougo/deoplete.nvim'
      Plug 'roxma/nvim-yarp'
      Plug 'roxma/vim-hug-neovim-rpc'
    endif
    Plug 'deoplete-plugins/deoplete-go', { 'do': 'make'}
    " do not forget to install jedi
    Plug 'deoplete-plugins/deoplete-jedi'
    " do not forget to install solargraph
    Plug 'uplus/deoplete-solargraph'
    call plug#end()
Enter fullscreen mode Exit fullscreen mode

link.

  • Plug 'fatih/vim-go' : as a Go developer, vim-go is a must have that allow you to check the documentation and go to the definition easily. It has many other cool features, you should check it out link.
  • Plug 'scrooloose/nerdcommenter' : commenting made easy link.
  • Plug 'scrooloose/nerdtree' : looking in the tree made easy and a bitter more understandable than the native one (at least for me) link.
  • Plug 'mattn/emmet-vim' : autogenerate tags when writing HTML, the most useful things for web-developers link.
  • Plug 'junegunn/fzf' : fast search at the tip of your finger, never use nerdtree again link.

making your coding more comfortable

  • Plug 'jiangmia/auto-pairs' : auto-complete parenthesis and other brackets link.
  • Plug 'tpope/vim-surround' : a bit hefty to learn to use but after that your will gain so much time and keystrokes when wrapping your functions and blocks link.
  • Plug 'itchyny/lightline.vim' : a nice tool line for you vim with many themes and very customizable link.
  • Plug 'maximbaz/lightline-ale' : display your linter errors and warnings in lightline link.

git

  • Plug 'airblade/vim-gutter' : display your changes in a gutter, undo them and preview them link.
  • Plugs 'itchyny/vim-gitbranch' : display the git branch in lightline in your active git repo link.
  • Plug 'junegunn/gv.vim' : not necessary but a nice explorer for your git repo and commits, useless if you use tig link.

bonus

  • Plug 'junegunn/goyo.vim' : get vim even more distraction free link.
  • Plug 'psliwka/vim-smoothie' : smoother scrolls link.
  • Plug 'mhinz/vim-startify' : a nice startup page with possibilities to get your previous buffers up and running at the tip of your fingers link.

colors

  • Plug 'ayu-theme/ayu-vim' : a orange based colorscheme amazing with redshift link.
  • Plug 'articicestudio/nord-vim' : a blue based colorscheme, perfect for day work link.

About it

Vim is an amazing tool, from the first day I heard about it, I had one idea in mind: using it. At that time, I didn't understood the purpose, I was not a developer not I was close to anything from programming. Years were passing by and I kept hearing about how awesome it was without having really tried it.

One day I became a developer, I tried using Vim but the overhead was too big, too complex. I couldn't keep my head around what I was supposed to do (code) and the editor. So I used Sublime Text and everything went as smoothly as it should go for someone learning to code.

Months were passing, Vim was calling me like a mermaid in the mist. I move to Vim mode in Sublime and used very little options to it. I tried to keep learning but it was increasingly difficult and none seemed to really make me a better developer. I was just faster at deleting lines. VSCode happened then, and I used the Vim mode as well but there trying to increasingly understand new concepts of development, as for Sublime, I tweaked VSCode as much as I could. I realised it isn't some much about the tool but the way you code: everyone needs different things.

I could only understand that with years of into development: what do I need fast, what type of feature I need at the tip of my fingers. This is the core reason you configure Vim: to be faster, to stop thinking and to match your patterns of working. Vim is the ultimate productivity machine but can also be a deep rabbit hole if you get sucked by it.

For example, I need to split screens fast (C-W + v|s), open terminals (:term in neovim), go back to function definitions (:GoDef in vim-go) and not repeat the same code over and over (dot operator and macros). Clearly, VSCode can do that, but for some reasons it didn't work for and we parted ways after 6 months.

I finally gave Vim a couple of unfocused weeks, with stackoverflow and cheatsheets all over my desk, I was learning it day by day, until I matched all my mind-paths to something that existed in Vim. I was getting there and it felt awesome.

This is when I realised something.

It seems that looking for a useful and productive code editor or IDE is first of all a look into your own development procedures and techniques. It is not about being cool or being fast, it is about being smart. What matters here is to become one with your tool, understanding it but also bending it to what you need.

What do you need when you code? What are the features that make you faster? Do you need split windows? Are you distracted by the large amount of features in an IDE (I know I am)? Are linters useful for you? Do you need to autofix your syntax? Color or not? There are many questions, many plugins and so much time lost in the depth of configuration.

Essentially, it is something you can only know if you have been developing for some time, but aren't too much linked into a tool. Vim takes time but I guess like the Stockholm syndrome, when you get into it, it's hard to discard all the work you put into it.

Finally, after all those days spent looking into the void of my own reflection in the screen. The almost perfect configuration appeared to me like the sun on a winter morning. It was it. I knew it.

Code was easy, things were happening like I wanted, how fast and nice as I wanted.

I found the exit. I exited Vim. Now we are walking together the paths of development.

Discussion

pic
Editor guide
Collapse
valdorvaldor profile image
David Valdivieso

I don't use any plugins. I only use some identation settings to use tabs instead of spaces (yes I use tabs) and show trailing spaces and that's it.

But I'm glad there is someone out there who thinks a console and VIM is all they need.

Collapse
tailnia2010 profile image
Meghnatis

hey. i am using vim for a year now. but i just was introduced to linting and i already have "ale" plugin that you mentioned first in my vimrc but the command :ALEFix does not work. and i actually don't know how to use it. i installed eslint too. but i don't know how to connect them and use them to style my code and fix errors. please help me. thank you very much and also your article was really understanding and well explained.

Collapse
joerter profile image
John Oerter

Have you tried fugitive for git integration?

Collapse
christalib profile image
chris Author

So I have, and GV.vim (github.com/junegunn/gv.vim ) is basing itself on fugitive.

But all in all, I am sometime confusing myself if I have too much overlays of stuff in vim. I don't mind using the vanilla git in a terminal next to me instead of having fugitive or bash wrappers.

Although, GV is pretty neat.

Collapse
ggcristo profile image
Cristo García

Did you try :Commits withing fzf.vim?

Thread Thread
christalib profile image
chris Author

O.M.G didn't know that feature, it's amazing! Thank you!

Collapse
vintharas profile image
Jaime 🔥🧙‍♂️🔥

Great article! Thanks for sharing your experience why Vim! 😁👍

Collapse
vintharas profile image
Jaime 🔥🧙‍♂️🔥

I've also being meaning to try the startify plugin, I'm installing it right now! 💪😁

Collapse
christalib profile image
chris Author

It's a great plugin. It is dispensable but this getting started page allows you to jump back to some projects even if you aren't in the directory or back to the buffer you were working on before. Feels like getting back at your desk instead of starting from a new one. :)

Collapse
ghost profile image
Ghost

For those who dislike parenthesis auto-complete I suggest 'kien/rainbow_parentheses.vim' it gives different colors to them based in the nesting level. And is easily configurable.

Collapse
omerxx profile image
Omer Hamerman

Nice! You missed the link for smoothie: replace / with -

Collapse
christalib profile image
chris Author

Thank you! It is fixed :)

Collapse
arrudaricardo profile image
Ricardo de Arruda

The links for vim-gutter, nord-vim and vim-gitbranch are broken.

Collapse
christalib profile image
chris Author

Fixed, thank you for noticing!