DEV Community

Cover image for the only 5 vim plugins i need
Hayden Rouille
Hayden Rouille

Posted on • Updated on

the only 5 vim plugins i need

I've been hooked on vim for the best part of 18 months now, and earlier this year I decided it was time to step away from my comfort of using the ultimate vim setup and make my own.

At the end of the day, most users won't touch half the features that come with a pre-configured setup that big, and it turned out I could strip what I actually used from it into my own vimrc fairly easy.

Whilst I have more than just the plugins below, these are the 5 I use the most frequently.

1. vim surround

GitHub logo tpope / vim-surround

surround.vim: Delete/change/add parentheses/quotes/XML-tags/much more with ease


Vim doesn't come with everything out of the box, part of the reason we love it. As simple as it is, vim surround makes editing code a breeze. How many times have you been in some js and realised you needed string interpolation? Vim surround makes this easy, simply press

cs"`

You can even change HTML tags with

cst<div>

2. vim commentary

GitHub logo tpope / vim-commentary

commentary.vim: comment stuff out


Tpope is at it again - vim commentary is another simple plugin that just makes life easier.

Want to comment out the 5 lines below in the correct format for the file you're in? Easy -

gc5j

The only one I've had some issues with is typescript & react, and for that i've just written the below in my vimrc

autocmd FileType javascript,javascriptreact,typescript,typescriptreact setlocal commentstring={/*\ %s\ */}

3. emmet vim

GitHub logo mattn / emmet-vim

emmet for vim: http://emmet.io/


Spending more time on front-end code recently has made me appreciate emmet even more. It's just one of those plugins you have to have in a code editor.

div.test>li.item*2

Will simply resolve to

<div class="test">
<li class="item"></li>
<li class="item"></li>
</div>

4. coc.nvim

GitHub logo neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.


That's right, I've left the best for last. Jump around files like it's no ones business with some simple key mappings, and have code suggestions/autocomplete in almost any language.

:coc-install coc-tsserver

and you're set up for javascript, giving you the best autocomplete you've seen. Ruby LSP? Easy, just

:coc-install solargraph

TSSever
Solarwind

There is even an LSP for TailwindCSS which I've been enjoying using recently, no more visiting the website every time you forget a classname!

TailwindCSS

One of the best things about vim is the movement - Not only does coc provide amazing autocomplete, but it just takes movement to the next level.

Add a few bindings to your vimrc and from JS imports, classes or methods in Ruby, whatever you want.

nmap <buffer> <leader>gd <Plug>(coc-definition)
nmap <buffer> <leader>gr <Plug>(coc-references)
Enter fullscreen mode Exit fullscreen mode

Go to the definition with your binding, and use vims built in jumping to get you right back where you were, no time wasted at all!

5. fzf

GitHub logo junegunn / fzf

🌸 A command-line fuzzy finder



If you haven't used fzf yet, you're going to be blown away. I've been using FZFs file searching in a project that has been developed for over 10 years and FZF still proves its, as they put themselves, blazingly fast.

I add some simple keybinds for easy access

nnoremap <C-T> :Files<cr>
nnoremap <Leader>b :Buffers<cr>
nnoremap <Leader>s :BLines<cr>
Enter fullscreen mode Exit fullscreen mode

And after that, it's smooth sailing. You even get a cool preview window!
Fzf

FZF and RG makes search a project easier than it's ever been.

Conclusion

Sitting down and writing my own vimrc, taking my favourite parts from different repositories and customising them took time, but has proved to be priceless.

As with anyone who uses vim will tell you, there is always more to learn, and that's what I love about it.

If you want to check out my dotfiles, you can see them below.

GitHub logo haydenrou / dotfiles

i3, Vim, Bash, Ruby, Typescript & React, Elixir, Golang & more!



Thanks for reading :)

Top comments (4)

Collapse
 
rowanu profile image
rowan

Wow this was good timing; was just about to reboot my .vimrc, and was still on the fence about coc.nvim and fzf.

Definitely going to give them a go now, thanks for sharing!

Collapse
 
hayden profile image
Hayden Rouille

They're excellent, I hope you enjoy using them too!

Collapse
 
aminnairi profile image
Amin

Hi there and thanks for sharing your Vim plugins with us.

What are the key differences for choosing Rg over vimgrep for instance? I have always found vimgrep to do the job just fine for now. What is your opinion on that one?

Collapse
 
hayden profile image
Hayden Rouille

Hey Amin! The main and possibly only argument worth noting would be speed. If you use Rg you'll really notice a speed difference, but mainly in big projects. You can map vimgrep to Rg too if you want.

Remember though, this is all preference, use what you like best - thats the beauty of vim!