Sunday, March 14, 2010

Using Project.tar.gz

Project.tar.gz (available here) is a plugin for the Vim text editor. It provides Vim users with a special window that allows quick access to a specific group of files. This special window is somewhat similar to Visual Studio’s Solution Explorer or Eclipse’s Project and Package Explorers.

Basics

Installation

Download project.tar.gz from here. The current version is 1.4.1. Extract its contents into a folder currently in your Vim runtimepath.
If you do not know where to extract the contents of project.tar.gz, the “preferred” directory depends on your operating system.
Linux, Unix, and Mac OS X users should use:
~/.vim/
Windows users should use: HOME\vimfiles where HOME is the user folder.
For example, if you are running Windows 7 (or Windows Vista) and your user name is “Principal Buttsavage”, and your user folder is on the C drive:
C:\Users\Principal Buttsavage\vimfiles\
Tar.gz support is not built into Windows, so those users need an application to open .tar.gz files. I suggest using 7-Zip or 7-Zip Portable, but there are many other programs out there.

Accessing Project.tar.gz documentation from vim help

Run vim and type the following while in normal mode:
:helptags directory/doc
where directory is your vimfiles directory. It’s that simple!

Basic Usage

Unlike similar solutions, project.vim requires users to setup a text file that contains information on one or more projects. Project.vim has a default text file that it uses:
$HOME/.vimprojects
To use this file as the project file, type the following while in vim’s normal mode:
:Project
What I prefer to do is use a separate file named ‘p’ in the main directory of a project. When I delete the project files, I do not have to remove the project in .vimprojects. To use a different file for the project viewer, type the following while in vim’s normal mode:
:Project filename
Where filename is the name of the file to use.
For details on how to define a project, be sure to to read project.txt (the help file in project.tar.gz).
After making (and loading) a project file, navigate it like you would any other file/directory in Vim. Put your cursor over a project and hit Enter to expand it. Put your cursor over a filename and hit Enter to open it. Press \r to automatically fill a project (see example below).

Sample Project File – p from CalculatorD

Code

Calculator_Project=~/CalculatorD CD=. {
makefile

Java_Files=src/CalculatorD filter="*.java" {
}
}

Resulting Project Display in Vim



(using the fantastic MountainDew color scheme)

I pressed '\r' while my cursor was on Java_Files to automatically fill-in the source files. This must be done any time you add files to a project.

How it compares to similar vim plugins

NERD Tree

NERD Tree is an excellent plugin for browsing files in directory form. It can serve as a Vim file browser and a side window for browsing directories while viewing files in other windows. The downside is that you have to view files in terms of folders, not in terms of projects.

Buffer Explorer

Want to open files that you’ve previously opened this session? Buffer Explorer is for you! It can’t be used for much beyond that, but is there anything wrong with that?

Myprojects

myprojects is a relative newcomer: its first version was released in 2009. It is still in alpha, but it shows some promise. It seems similar to project.tar.gz, only it uses indentation instead of curly braces to define projects. I couldn't get it to work properly, but perhaps you would have better luck with it.

1 comment:

rtw314 said...

Thanks for this article! I couldn't figure out how to use this plugin and the help files were somewhat difficult to understand. Now I have a better grasp of how to use it my productivity should increase quite a bit. Thanks again!

Post a Comment