Sublime Forum

How to add current system timestamp in snippet when triggered

#1

Hi folks,
Recently, I started using sublime text (Stable Channel, Build 4126). I use following snippet frequently while coding. However, I need to insert timestamp after TimeStamp: <_here_> which I am not able to figure out. To be precise, when I write consolecp and hit tab, following snippet gets embed in the code but not able to insert system timestamp when this snippet was invoked.

Also, I don’t want to press any other explicit key except ‘tab’ after I write consolecp, to insert timestamp.

<snippet>
	<content><![CDATA[
/**  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    |                                               |
    | Creator  : Piyush Rajendra Chaudhari          |
    | TimeStamp:                                    |
    |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|
**/
#include <bits/stdc++.h>

using namespace std;

int main () {
  ios::sync_with_stdio (false);
  cin.tie (0);
  ${1}

 
  return 0;
}
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>consolecp</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>source.c++</scope>
</snippet>

Upd: I have installed a package ‘InsertDate’, but not able to figure how to use it in this case.
Looking forward for the working solution.
Thank you.

0 Likes