views:

662

answers:

6

Does anyone know of a short cut to place my name and the date where the cursor is i.e.

 //021208 DarkAxi0m

so i don't keep check what the date is when i'm adding comments.

Im using Delphi7, with CnPack And GExperts Installed. I think it should be able to be done with one of those experts.

+1  A: 

Never mind found one in CnPack/Soure Templates Added the template

  //%Date% DarkAxi0m

Note: i should look in the menus more closely

Christopher Chase
+1  A: 

You might also look at the Live Templates feature, which can be scripted to do just what you want:

http://cc.codegear.com/Item/24990

Don't be put off by the name, it includes a template script to include the date, time, including the ability to format it as you want.

Nick Hodges
looks good, but i don't think it will work with delphi7
Christopher Chase
Live templates does not exist in Delphi 7, Nick. The OP stated he's using D7 on the question.
Fabricio Araujo
+2  A: 

It is also simple to do with GExperts' Expand Macro Template (found in Editor Experts).

I use this expansion to insert yyyy-mm-dd at the current position:

%YEAR%-%MONTH%-%DAY%|

gabr
+3  A: 

I use GExperts to do this, like so:

in the

GExperts\Configuration

Select the Editor Experts tab.

In the list of experts, select

Insert Date\Time

Click on the configuration, insert the desired text:

'//' ddmmyy 'DarkAxi0m: ' //021208 DarkAxi0m:

After, to insert your new Date name comment all you need to do is:

ctrl+alt+a

I setup most programmers at the job like that.

CheGueVerra
+1  A: 

For a solution that will work in most applications under Windows, not only in Delphi, you can use Authotkey (free, autohotkey.com). One of its many features is the ability to expand strings that you type - typically used for autocorrecting typos.

I start all my shortcut strings with a semicolon, since it practically never leads strings I type in real life, so in your example, to insert a comment-date-username sequence, I would want to type semicolon, slash, slash:

;//

The Authotkey script (which you can put in an .ahk text file and add the file to Autostart) would look like this:

::;//::                             ; this means: when I type ";//", do what follows
FormatTime, curDate,, yyyy-MM-dd    ; the double comma is intended
SendInput // %curDate% %A_UserName% ; variable expansion
return

This produces the following output:

// 2008-12-05 moodforaday

AHK syntax is a little dense, but there is an extensive help file.

On edit: this script could be expanded to apply the correct comment syntax depending on the IDE you are working in at the moment. You would detect active window title, find a signature substring ("Delphi") and choose the proper comment character(s). This way you could type the same hotstring to insert your comment regardless of the current IDE or language. You can also use SendInput to position the caret the way Delphi templates do.

moodforaday
This is my preferred solution. It's great for entering your email address (how many times do they ask you to confirm it on a web site?). I've programmed AHK to insert two flavours of date / time at the cursor in any Application:Usual: 26.07.09For file names or record purposes: 2009.07.26-075013The latter sorts in date order.Bri
Brian Frost
+1  A: 

Here is a variation with GExperts (www.gexperts.org) that makes it easy to search for changes based on developer or date.

Example of output and comment:

   //07.25.2009 (SLB20090725) - Added 3rd optional parameter.

Besides an easily readable date I can easy search for comments programmer, by year, year+month etc.) For example I can search for (SLB200905 for any comments I logged in May of 2009.

To do: Under the GExperts menu open Configuration... (at the bottom of the list) then select the Editor Experts tab. Locate 'Insert Date/Time' and double click on it.

//mm.dd.yyyy '(ABC'yyyymmdd') -'

Where ABC is the programmers name, initials, id, or whatever.

Then use Ctrl-Alt-A when in Delphi's IDE to insert

This should work in any verison of Delphi supported by GExperts.

TheSteven