Episode: 174
Title: HPR0174: VIM is my IDE
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr0174/hpr0174.mp3
Transcribed: 2025-10-07 12:54:04

---

.
Hello and welcome to another episode of Hacker Public Radio.
My name is Drulu and we're going to be talking about how to turn VIM into your own do-it-yourself IDE.
I've been using VI on and off for oh since about 87 I guess.
Every once in a while I'd be computing along and remember there was some really simple easy-to-use basic text editor
that I always had to remember the odd keyboard commands for and kind of rediscover VI and get into it again.
Now that I'm doing more Linux stuff of course I don't have to do that anymore.
Most recently I discovered some really awesome tools for turning your love of VIM into a real do-it-yourself IDE.
If you're new to VIM, definitely hang in there and stick it out, you'll pick it up and learn to love it.
I first learned about these IDE tools for VIM from this week in Django which is over at this week in Django spelled djangio.com.
Michael Treer and Brian Rosner were looking to move from text mate on the Macintosh back into using VIM as their primary development environment.
So they were talking about these tools a little bit so I went and took a look and figured out how to do it.
This is what this tutorial is about. I'm going to cover three scripts.
The first is Snippet's EMU. The second one is NerdTree and the last one is TagList.
Snippet's EMU and NerdTree are both located at VIM.org and then TagList you can find it SourceForge.
It's VIM-TAG-LIST.SourceForge.net.
Go ahead and go over there and download those programs.
We're going to be downloading two packages from www.vim.org.
Click on the scripts link on the left-hand side and when that opens up, click browse all and then scroll to the bottom of the page and just type in Snippet
and Nerd in the keyword search. Both these programs will come up with links and you can go ahead and go download those from there.
For Snippet's, you'll need to click on the Snippet link and grab the first two files that's top of the list.
There's going to be a snippy underscore plug-in.vba and a snippy underscore bundles.vba.
The plug-in part is the script that actually does the work. Snippy bundles is the group of individual language files for the different Snippet code groups.
So you'll have snippets for PHP, snippets for Django, snippets for Python, all kinds of different things.
So go ahead and grab both of those and then go back and grab the NerdTree.
And then from here, you'll want to go to sourceforge, go to vim-taglist.sourceforge.net and grab the latest version there and then we'll talk about installing.
Snippet's comes in a couple of files, they're VBA files, but we'll talk about that in a minute.
Ubuntu Hardy seemed to already have the correct Vim packages installed when I started doing all this stuff.
But Debian4 etch required that I do an apt-get install of VimFull, which is VIN-FULL.
Debian has a startup kind of first settings setup file located at user, shareVim, Vim71 on my machine, Debian.Vim.
So that's slash user slash share slash Vim slash Vim71 slash DEBIN.VIM.
That's a Vim setup file, so that will be a global Vim settings file that Debian systems seem to be using as a default.
You can always go in there and edit things just like you're in the et cetera directory.
Also on the Ubuntu Debian, there is a file called filetype.vim in your default user.vim directory.
And that just runs everything located in the FT plugin directory, which we'll go over here in a moment.
For my system, I have a Python default tab settings and particulars setup in my FT plugin slash Python.vim file.
And that's just a list of options that get set when you start up Vim and you happen to be editing a .py file.
You may have noticed that FT plugin stands for file type plugin so that when you have a file that you're editing, Vim will know that if you're editing a Python file to look at the python.vim file for settings on that particular language.
And the same would work for PHP files or shell files, probably .bash files.
Well, for now, let's go look at the Vim directory.
So if you go to your home directory, slash home slash whatever your username is slash .vim for CD tilde slash .vim.
And do an LS, so do a directory listing on your Vim directory.
LS asterisk, you'll see on Debian anyway, filetype.vim directory called colors directory called doc, a directory called FT detect,
and a directory called FT plugin, another directory called plugin, and you'll probably have a syntax directory.
And we'll go over all these in just a moment.
I actually have an after directory in my Vim directory, and that is installed by snippets which will also go over here in a few minutes.
As you might expect, the colors directory holds color settings for Vim.
You can go to Vim.org and get a bunch of template files.
They're also .vim files. That will set different color schemes.
So you can kind of mimic also the kind of background colors of the text mate type editor.
Some others you can customize your own and put your own stuff in there.
The doc directory will hold your Vim help files.
So if you're ever using Vim and you type a colon to get down to command mode and you type help and some command name, you'll get a help file.
And the help file will be in one of two states.
Either you'll see a bunch of highlighted areas and underlines with special, you know, pipe brackets around things that are actually keyword tags that let you jump through the file to get to different help items.
Or you'll see something that's just plain text un-highlighted which does no kind of jumping around.
And on the docs, the way that the help works is you do colon help your command or script name, whatever you happen to be using.
And you can scroll over or mouse over depending on what you're using.
I use arrow keys and jkl to get over to one of the highlighted words that are the keyword tags.
And you can hold down control key and type a close bracket, which is a closed square bracket, not the closed brace, but the closed square bracket.
And that will jump to that particular keyword.
The way that works is help files are set up so that some scripts will automatically build a help file tag list for you.
And in some cases you'll have to go create that tag list manually.
So let's say your help file doesn't have the highlighted tag list and your control closed square bracket doesn't jump anywhere.
Well, what you do then is if you have help that you can see that the help that you're looking at is giving you a help file.
So you would open up them or by anywhere, any kind of file, and you can resource your help files, do a colon to get into command mode.
And then you're going to use the help tags command on your VIM doc directory.
In my case, I would open a file with VIM anywhere on my computer.
And I would type colon.
And then help tags, H-E-L-P-T-A-G-S, all in one line, space, tilde, slash.bim slash doc, and enter.
And what that'll do is that'll go through my entire VIM doc directory.
All my help files there will be reread.
And there's a little file in there called tags, which VIM creates all those tag hooks so that when you are scrolling around through your help file,
you can get that control closed square bracket key word jumping thing to work for you.
Another directory you probably have is the FT detect directory.
And I had installed VIM Outliner, never really used it much.
And in there, I have a VO underscore base dot VIM file in the FT detect directory.
And I suppose that does something for that.
There's no other files in my system, so I'm not really going to go over that much.
The FT plugin directory is a directory that holds your, as we said before, your file type plugin.
For snippets, which we'll go into a few minutes does is you put all your snippet code into the FT plugin directory.
And snippets will pick that up and know what snippets to use for your particular file type.
Another thing you have in here is going to be, for instance, I have Python dot VIM.
Anytime I want to edit a Python file, VIM knows what my Python settings are.
And it gets that from the Python dot VIM file that is located here in FT plugin.
Another directory is just plain plugin, plugin by itself.
And that will hold the main script that are your plugin script.
We've got snippets EMU dot VIM, nerd underscore tree dot VIM and tag list dot VIM.
Those are the main script code files and those go in the plugin directory under your home dot VIM directory.
When I installed my nerd tree and tag list to the files I downloaded were zip files.
Nerd tree was in a zip file and tag list was in a zip file.
And all I had to do there is change into my tilde slash dot VIM directory, my home dot VIM directory.
And unzip those files there and they actually the documentation file and the script file and the proper directory.
So it it plugged in tag list dot VIM into my plugin directory and also put the help dot TXT tag list file into the dot directory.
And I believe I had to run to the dot directory and resource that with that help tags command to get the tag list help to come up.
I have another directory called syntax which I expect is used for putting VIM files that handle syntax highlighting and that kind of thing.
Since my Python highlighting instruction is in the FT plugin slash Python dot VIM file.
I don't have a Python syntax file in my syntax directory.
So I've got HTML dot VIM and BO underscore base dot VIM which one would be the HTML highlighting one would be BO underscore base.
Now that you kind of know where files and scripts and things are supposed to go we'll talk about the scripts directly.
Main one is going to be snippets EMU snippets EMU is a really neat little script basically it was designed to replace text make.
So the way that works is you type in a short phrase and hit the tab key and you're predefined snippet code replaces that phrase with a function name and then also places your cursor in the proper place to start adding variable names for your function.
For example or whatever you've defined it to be and snippets EMU also comes with what's called bundles and there's a scripts file and a bundles file.
And the bundles actually have predefined settings for different functions and different programs and one that I was looking at was Django and there's two files for Django one is for templates and one is for models.
And if you know anything about that that comes in very handy. You'll need to download two different files to get the latest snippet code.
Originally they all stuck everything on one file but since the code for the individual languages changes more than the actual snippet code that runs to perform the operations they split them out into two different files.
So the first one is a script itself and that will automatically install into the plugin directory and the other file is different groups of snippets for the individual languages.
The latest files are going to be .vba file. That stands for VIMBALL file just kind of like a tarball file but it's VIMM. All you need to do is save that file somewhere, go to that directory and open it with VIMM and you'll get a little instruction depending on what shell you're running I guess probably.
That tells you you need to source the file and there's going to be a little bit of code there.
And basically what that is you open it it gives you instructions you hit enter and you're going to hit colon to get the command mode and then you're going to type S0 for source and then a space and then a percent sign and then enter.
And what that does it runs the VBA script VIMBALL script anyway not visual basic and it installs into your default home directory hopefully in the right places.
After you've sourced your VIMBALL file you should have a directory under your home.vim directory called after and then under the after directory you should have another directory FT plugin.
If that's not created you have to create it yourself that would be the make-dure command. So mkdir space tilldayslash.vim slash after slash FT plugin.
Since snippets will depend on a file type you've got to name the snippets files in the FT plugin directory a special way.
When I first installed this I was looking to use the Django snippets and they didn't work because the code that's on the VIMM.org website did not name the files correctly.
So they thought that Django was a file type in the Django framework and actually Django files are just Python files.
So instead of naming them Django underscore whatever they were dot VIM they had to be renamed to Python underscore Django whatever the file name snippet dot VIM.
And that seemed to work. Just leave them the way they are and do a sim link to those files without changing the actual file name.
So let's say you're working on a Python project that reports where the last sighting of say clotu, dirk, Schnurkelberger, chess griffin, dan, alan, pat, link, techie geek or some other crazy Linux character are at some given interval.
Well, you would name your snippet Python underscore clotu underscore Schnurkelberger underscore griffin underscore TLTS underscore crazy underscore techie snippet SNIPPET dot VIMM.
And snippets will find your code every time. So as long as your file name starts with Python underscore and ends with snippet dot VIMM.
Every time you open a .py file for Python your snippet in that snippet dot VIMM file will be available to you.
Another part of this IDE setup is going to be nerd tree. And this is pretty neat. This is looking at your file system using them in a vertically separated window.
So if you've ever seen the Nautilus file manager, you know you've got your files on the right and in a little skinny area on your left, you've got your directory tree depending on how you set it up anyway.
Well, this is the same thing, but it's all through VIMM. So you've got a directory tree on your left in the VIMM file you're editing on your right.
This is one of those that are in a zip file. So I switched to my .VIMM directory. I did a UNZIP space, my nerd tree file, whatever it happens to be.
And it unzipped the nerd tree script and put it in the plugin directory and also put my help file in my doc directory.
And once again, you'll need to go to your doc directory and open up any one of those files and resource your help tags.
So open up any file in VIMM and do colon, help tag, actually help to you would be the shortcut space, your VIMM directory.
So in my case, it's tilde slash dot VM slash dot and that will resource your help file for the nerd tree.
And of course, you can always just install these things and then go do that part just once and make sure everything is picked up.
So if you're already in VIMM, you want to exit VIMM, open up a new file in VIMM and wherever you are, it doesn't really matter.
You should be able to type a colon and type capital any RDT and then lowercase REE for nerd tree and hit enter and that will open up the nerd tree window.
So you should see your cursor in the left hand window and then you can also use your standard VIMM control.
So if you type a control W and a left arrow key, for instance, that will jump over into the left window.
If you hold down control, hit W and then hit the right arrow key, that will put you back into your editing window.
So, you know, standard VIMM keys apply here and you can go up and down the directory tree and just type O to open the file.
To go up a directory, scroll over to wherever you want to go up from and hit U, that will go up one.
And if you hit T, that will traverse down one.
It's really easy to get around. You can also type Geo to go to the file.
Do a colon help any capital any RDT, lowercase REE and enter and that will take you to the help file.
You can also go over to the nerd tree file tree on your left hand side and hit the question mark.
And that will open up a brief help explanation also.
The next part of this IDE, which is really handy, is the tag list.
And this has one of the requirement of exuberant CTags to work properly in Ubuntu.
So, I had to do apt-get install EX-U-B-E-R-A-N-T underscore CT-A-G-S to get the exuberant tags installed.
That is located in the Ubuntu repository.
And it's also located on SourceForge if you want to just straight install it yourself at ctags.sourceforge.net.
Once tag list is installed, type a colon to get into command mode.
Type a capital T and then lowercase LIST capital O lowercase PEN for open and hit enter and that will open a tag list.
And what that does is it tags all of the functions in your file that you're viewing.
So, if you have a PHP file or you have a Python file, whatever functions, classes, definitions, anything like that will appear as a tag tree on your left hand side.
Once you're in the tag tree, scroll over to any of the words in the tag tree list and hit enter.
And that will jump to that tag inside the file that you're editing and you continue editing at that point.
Another great feature is the tags accumulate as you edit other files.
You can use control W for window, hit the direction of the window to your left and that will pop over into the tag list.
And you just scroll over your tag that part of your file in your file that you're editing.
So, that is super handy and great part of this IDE.
A couple of other scripts to explore and I'll leave this up to you is the nerd commenter that's capital NERD underscore COMMNTER, also available at VIM.org.
And then also another one called Lodgeit. It's LODGEIT.
What that does, it's what's called a paste bin for your VIM.
So, what that allows you to do is post some snippet of code that you're working on to an online paste bin.
So, if you're talking to somebody at IRC and you say, I've got a problem with this area of code, you can yank that bit of code, put it in a buffer and VIM.
And then it will upload it to the paste bin online.
And then the other person on IRC can then go look at that, get a copy of it or whatever, and help you out with your code.
So, that's a pretty cool little feature. I haven't actually used that myself.
I've been using a paste bin DPaste.com and that's a Django project also that is really cool little thing.
You post up your code and somebody else can look at it and it has an expiry time so that you're not wasting a bunch of space on their server and it's pretty cool.
So, definitely check that out.
There's a couple of more via tips for you. If you don't know already, you've got a.vimrc file in your home directory.
And if you don't have it, no big deal.
On Debian, you're actually using a Debian.vim file as your starting point.
But you can have your own personal settings in.vimrc in your home folder.
And some neat little key binding things you can add so you can just hit a function key and open up an urge tree or hit a function key and open up your tag list.
It is to use the in no remap function to map a key to your particular project that you want to use.
Open up.vimrc in your home directory.
You're going to type this one liner command in N-O-R-E-M-A-P space, less than S-I-L-E-N-T, greater than space, another less than capital F.
And the number of function key you want to assign this function to, and then a greater than space, colon, capital N-E-R-D-T, lowercase R-E-E, and then less than capital C, capital R, and then a greater than, and then enter.
And just leave that on one line by itself.
To get that to work, you're probably going to need to exit out of them and then open up some other file that you want to edit for this thing to be applied.
Then the next time you hit that function key while you're in vim, that should open up your nerd tree.
So basically what it's doing is it's executing the colon nerd tree just like you would type it yourself and press enter.
So to open up your nerd tree.
Tag list has a similar one, and it actually has a tag list toggle so that you can click on and click off your tag list without having to open it and close it.
Like a nerd tree.
One more thing, on nerd tree while you're in the nerd tree window, if you type a queue, that will quit nerd tree and return you back to whatever file you're editing on before you open up nerd tree.
So that's a little tip there.
For the tag list, you're going to have the same type of line.
It's going to be just copy from the previous, but instead of colon nerd tree, you're going to do colon capital T lowercase LIST capital T lowercase OGGLE.
And then you're going to end with that less than capital CR greater than.
And then just have that on one line by itself and you should have T list toggle.
So next time you open up some file you're editing, you can turn on your tag list and it should work.
So this is the part where I tell Dan, Alan, Pat and Lee, thank you for inspiring me to put this thing out here.
Pat was nice enough to call me up on a listener episode way back I think probably in February or so.
And I really enjoyed that and I've been planning on doing something like this for a while and finally got around to it.
So hopefully I'll be contributing some more as time permits, so I'll talk to you later.
Thank you for listening to Hack with Public Radio.
HPR is sponsored by Carol.net, so head on over to C-A-R-O dot-N-T for all of us here.
Thank you.
