Author Topic: Getting Current FileName as a Comment  (Read 1694 times)

lwb78750

  • Community Member
  • Posts: 53
  • Hero Points: 1
  • Senior Software Engineer, C++, Qt, C, etc...
Getting Current FileName as a Comment
« on: August 10, 2011, 06:57:38 pm »
Is there an easy way to have the current pathname/filename inserted in my file as a comment?

Something like this:

// foo/bar/filename.cpp

Thanks!

Rodney

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 706
  • Hero Points: 45
Re: Getting Current FileName as a Comment
« Reply #1 on: August 10, 2011, 09:18:57 pm »
Look at help topic "Creating a Language-Specific Alias". You want the %\f escape sequence.

--rodney++

lwb78750

  • Community Member
  • Posts: 53
  • Hero Points: 1
  • Senior Software Engineer, C++, Qt, C, etc...
Re: Getting Current FileName as a Comment
« Reply #2 on: August 11, 2011, 07:40:21 pm »
Thanks for the pointer - The Alias feature is very cool!

ronw

  • Community Member
  • Posts: 36
  • Hero Points: 0
Re: Getting Current FileName as a Comment
« Reply #3 on: August 18, 2011, 02:50:16 pm »
If you are using a version control system (which I recommend, even for personal, non-work projects), it would most likely be better to use your VCS's keyword substitution feature to insert the file name into a comment. This way, if you rename the file, the comment will be updated automatically.

In many VCSs, the following will work:

/* $Source$ */

will become:

/* $Source: somefile.c$ */

If/when you rename the file, after the next commit, it will automatically update:

/* $Source: newname.c$ */