CodeItNow

DoItNow

Introduction

DoItNow is an addin for Microsoft Visual Studio 2005 which I wrote a while ago to help out with interacting with Perforce. Since then I’ve added a lot more features which speed up navigation around the IDE and writing code.

You can download the addin and source for free here.

I’m making this available because several people have asked me for it, but please beware that I’ve tailored it to suit my needs, and no more! There are many obvious extensions (like supporting multiple source control systems, turning features on and off etc.) that would be easy to add, so if you’re interested in doing something like this then please let me know and I’ll add you as a contributor on google code.
Thanks to Todd Scott for helping out with bug fixing and adding new features.

Features

Some of the following features are language dependent, and will disable themselves if the current project is incompatible.

Open Solution

Shows a search box where you can type in the name of the solution you want to open. In order to start using this feature, you must first set up the search paths in the options.

Open File

Shows a search box where you can type in the name of any file in the solution and it will open it.

Open Test

This feature works on the assumption that all unit test files are in a folder named ‘Test’ and are have the same filename as the class, but with an additional ‘Test’ prefix.

e.g. MyLib\Test\TestFoo.cpp will match up with MyLib\Foo.cpp

This feature closes all open windows and splits the view vertically between the test and the implementation file. I find this is a very useful way to do test-driven development if you have a wide enough monitor.

Insert Include

For C++ only, this shows the search box and determines the best path to the include file and inserts the include directive at the cursor location. It automatically switches between using quotes and angled brackets based on the include file location.

Find Function

Shows the incremental search box, and jumps to that function within the file. Please note that I’m at the mercy of intellisense here, so sometimes it doesn’t pick every function up.

Toggle Header and Cpp

This toggles between a header file and cpp file if they have the same name. Note that it toggles to closest match based on number of directory changes away.

Toggle Implementation and Test

If the test filename meets the same conditions as specified in the Open Test feature, then this will toggle between the test and the implementation. For C# this just jumps to the correct C# file, and for C++ it will try to match the cpp file first, and fall back on the header if it can’t be found.

Next/Previous Camel Case Word (Extend)

If you write verbose test names like me, then it can be a bit annoying that you can’t navigate between the words. This feature is designed to get round that. I’ve bound it to the same keys as next/previous word except with the ‘alt’ key held too. By holding down shift, you can highlight the words too.

Source Control

This attempts to connect to a perforce server to check out/add/delete files. If you don’t use perforce, or don’t want this feature, then you’ll have to remove it from the list in Connect.cs and recompile since I haven’t gotten round to enabling/disabling features. If you want, you can also just swap out the path to perforce, and the options to get it working with another source control system.

Note that if it can’t connect to perforce, then it will attempt to go into an ‘offline’ mode. It will fake source control operations and store them in a file in the plugin directory to be sent at a later date. I wouldn’t recommend doing anything too fancy in this mode (like say add a new file, delete it, then add it again), since changes in the state of perforce while you are offline can cause issues. It is mainly intended so that you can keep editing files when you are offline.

If perforce comes back online while you are coding, you can run the Check Source Control Status command which will test to see if perforce is available, and if so, purge all the source control operations at that time. It will write the list off commands to the output window.

DoItNow always checks for a perforce connection on startup, and will purge the pending operations if it sees that the connection is valid.

P4Win

These features all operate on the currently selected file, either in the text editor or the solution explorer. You can show the file in P4Win, diff it with the depot file, or show the history.

Code Templates

When you press tab, DoItNow looks at the word you just typed and searches the code templates for a matching trigger. If it finds a trigger then it will replace the word with the template text. You can add, remove and edit the code templates in the options.

When you enclose a string inside $(), the selection will jump to that string so that you can quickly replace it. For example, you may add a template for the trigger ‘for’ like this:

for (int i = 0; i < $(max); ++i)
{
}

As soon as you type ‘for’, then press tab, it will insert the template text, format it, and select the $(max) string. If you use the macro $(filename), then it will be replaced with the current filename without the extension.

Installation

  • Unrar to addins folder.
  • If you have an older version installed then be sure to run ‘devenv /ResetAddin DoItNow2.Connect’. This will reset all the menus.

Comments are closed.