
Use VSCode snippet to add timestamp
I know, all are well written in the documentation. This is a note for myself to use VSCode/VSCodium snippets in Linux.
-
Setup a snippet by clicking
Ctrl + Shift + P
, selectSnippets: Configure Snippets
. -
Select
New Global Snippets file...
-
Put something like this inside the snippet:
{
"Insert timestamp": {
"prefix": "date",
"description": "Output a date in timestamp (YY-MM-DDHH:MM:SS)",
"body": [
"$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
]
}
}
This snippet can add a timestamp to any files you want. The prefix of the snippet is date
. Remember this.
-
Open any files and type
date
. I hope I can see autocomplete pops up but nothing. -
Go to menu, click
Preferences -> Settings
. -
Setup "Editor: Tab Completion" to
onlySnippets
, if it wasoff
originally
Go to your file, type date
and click Tab
key. Ta-da, see a timestamp in your file!
You can also add multiple lines like this in the body.
"body": [
"## $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
"### A title",
"- ",
"",
"### Something here",
"- ",
"",
"### Another thing here",
"- ",
"",
]
Done!