Implementing the Endwise Plugin for Smart Auto Complete Behavior in Vim
This guide walks through how to integrate the Endwise Vim plugin in order to add Ruby based auto completion.This include behavior such as adding an `end` to methods and conditionals.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

In continuing our journey on learning how to integrate some VIM plugins that are gonna help us, I want to look at a plug in called VIM-Endwise. Now I want to make one statement before we continue on. If you have come from a IDE kind of set up, such as Eclipse or some type of visual studio version, or something like that, you may be used to the concept of intelasense and autocomplete.

VIM, even though you could jerry rig it, and I have seen individuals and developers who have implemented all kinds of plugins to have all of the Ruby methods loaded in, or somethings for rails loaded in. As good as those are I really am not a huge fan of it because I think it kind of clutters up the process. I think it slows down the system and therefore I'm not a huge fan of all kinds of autocomplete.

However, one thing I really do like is having smart kind of autocomplete for certain code snippets that it makes no sense not to have. For example, here I love using the VIM endwise plugin.

large

And what it does is it simply adds an end in Ruby. So anytime that you create a method, so if you type in "def" and the method name you're always gonna want to have "end", it makes no sense not to have the "end" in there. The same thing if you put "if", you're always gonna want to have an "end" after the block. So with this, I think this is a smart kind of autocomplete because it means I don't have to go and type that in manually.

So lets see how we can integrate this. As always we're going to CD into VIM bundle, I already have this installed but if you type LS you can see that I have VIM-endwise installed right here. And so if you do not have it installed simply copy this code and paste it in right here.

git clone git://github.com/tpope/vim-endwise.git

I'm not gonna do it since that would just create a duplicate error. But if you do not have it run that code and you'll be good to go.

Now lets open up the VIM RC file, and come down to the end and now lets copy our runtime path. By the way, if you're using Pathogen or something like that, you can auto-load all of these. So anything inside of the bundle, you can have it run if you bring in a plugin manager. I'm not a huge plugin kind of guy, I like having a very limited number of them as you can see. But if you do want to have something like that feel free to do it and then you can have those auto-loaded.

I'm going to bring in VIM-endwise, hit save and now let me go back to the correct spot. So I'm going to go to code/devcamp-tutorials/vim-guides/vim-examples and now if I open up that Ruby file. If I come down to the end here and I type in "def" something, you can see they adds that "end", and if I type in "if", we'll just say "if true", you can see we now have an "end" right here.

large

This was really cool, this is the kind of autocomplete I actually like. Notice how fast it is, and it doesn't load up our page with a million different potential method names, and the kind of things that an actually IDE has. If you want that kind of experience then VIM may not be the best solution for you, in that case you might want to go with something like Rubymine or something like that.

That's personally not what I like. However, everyone has their different preference, I have no problem with the developers that like to use a full IDE, everyone has something that they like. I personally like something a little bit more lightweight, that I can customize to my hearts content, and that's the reason that I go with that. So this is how you can integrate VIM-endwise as a plugin in VIM.

Resources