With a little bit of work you can actually set up Vim to give you pretty good suggestions (not just based on dumb strings!), great highlighting, perfect indentation and automatic linting. If you haven’t tried this kind of thing before, welcome to the wonderful world of Vim bundle soup.
Managing the bundles
I use Vundle to manage all of my bundles, I’d recommend it to anyone looking to manage an extensive amount of bundles. It’s pretty easy to use and is kind of built for downloading from GitHub, which is where all the bundles I am going to suggest are located.
I’m not going to cover using Vundle here because the repository covers it perfectly. So you should go and get Vundle set up before proceeding, it should only take a couple of minutes.
All things syntax
Colours (British spelling, deal with it)
First, you will want to make sure that you have decent normal Vim colouring by adding something like this to your
1 2 3 4
This is mainly geared towards terminal Vim, so just take what you need. It will help to enable the 256 colour pallet, enable syntax highlighting, let Vim know we want a dark background and light foreground and finally set a different colour scheme.
After configuring and executing
Indenting (plus a couple of extra visual features)
The perfect bundle to compliment
You can combine
nathanaelkane/vim-indent-guides to get lovely highlighting for your perfectly indented callback hell. It’s a great indicator for what is lined up with what.
You’ll also need to actually enable indentation in Vim if you haven’t already.
Automate some typing
One bundle I can’t live without is
Raimondi/delimitMate, it will automatically add the closing quote, bracket or any other thing you’re typing that needs a counterpart character to stop your browser going haywire on the next refresh.
Something I’ve found to be very useful, which doesn’t require any bundles other than
delimitMate really, is to add a key binding that will split my current line. So if I type
delimitMate will insert
} after my cursor, then I can execute my binding that will insert a new line in the middle of the two ready to receive some code.
1 2 3 4 5 6 7 8 9 10 11
This is actually very easy to set up, all you need to do is add this to your
.vimrc and tweak it as you see fit.
That will map
Ctrl+C whilst still within insert mode to the line splitting command. You can obviously rebind it if you want, but I think this works really well.
If you need linting in any language you should turn to
scrooloose/syntastic. It doesn’t do much on its own, but combine it with an external linter and you have amazing live linting with indicators pointing to your problems within your actual code.
1 2 3 4 5
So once you have
Amazing code completion
This is the most complicated thing to get going, but it’s still pretty easy as install processes go. My first suggestion for auto completing your code would be to install
1 2 3 4 5 6 7
Now to put the icing on the cake:
You will need to do some extra install work for both Tern and YouCompleteMe though, so please be sure to read though there documentation. YouCompleteMe requires you to compile a module to enable ridiculously fast completion and Tern needs to you go into it’s directory and download it’s NPM dependencies. Once done though, they will “just work”.
Hopefully you will now get to enjoy a similar environment to me. If you like the kind of bundles and configuration options I use then you might want to cherry-pick even more from my Vim configuration repository. It’s kind of spilled over into Tmux and Bash configuration now too, so you should be able to find at least one nice thing in there.