0

I am getting tired of adding the date when I add a comment about some change I am making in the code. I am required to start comments like this:

// 14/03/24 fj: some comment

I don't need to repeat it on continued lines, just the first.

I am trying to create a code snippet to do this, but can't figure out how to reference the date inside my CDATA block. I tried searching, but couldn't find anything. Any ideas/links/etc.?

Thanks!

4
  • 1
    See stackoverflow.com/questions/3469324/… . Commented Mar 24, 2015 at 20:55
  • this seems like the kind of thing source control is for, not inline comments :O Commented Mar 24, 2015 at 20:58
  • 1
    This is why God gave us version control systems. You can always check to see when the comment was created that way. Also, no links. You can create a simple console app that copies "// {0} {1}:" (current date, current user values passed in) to the clipboard. Add it as an external program, map it to a key combo. Then all you have to do is, for example, shift-ctrl-V (runs app), ctrl-v (creates comment). Type away. Commented Mar 24, 2015 at 20:58
  • We use version control and I agree. But note the above phrase: "I am required to..." Will consider your suggestion though, thanks. Commented Mar 24, 2015 at 22:26

1 Answer 1

2

I'd recommend creating an AutoHotkey script for yourself, as code snippets have very limited logic available to them. Using AutoHotkey has the added bonus of working everywhere, and not being language specific.

Here's the AutoHotkey script you could use:

::\stamp::
FormatTime, TimeString,, ShortDate
Send %TimeString% fj
return

Typing \stamp will replace \stamp with 3/24/2015 fj

Sign up to request clarification or add additional context in comments.

1 Comment

this seems like a valid way to solve OPs problem... why the downvote?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.