VSCode Snippets to Speed Up Time/Task Management Files Creation

In the series of articles on my time/task management approach, one article is dedicated to the tool set (VSCode + OrgMode) I use to track my tasks and performance. Since then, a number of people has asked me to share the templates of the week, month and year files what I did after the first request. However, recently I have discovered an approach that allows me to speed up the creation of the year, month and week files. In this article, I share the details of this improvement.

Table of Contents

VSCode User Snippets

To speed up the creation of the time/task management files, I have started using the VSCode Snippets feature. In VSCode, a user can create a set of snippets that would be activated when you start typing a keyword. Moreover, these snippets are language-specific, e.g., you can create a snippet for markdown file that will not be available while you are developing, e.g., Python code. Luckily, the Org Mode extension defines a separate language called Org, which we will assign our snippets considered in this article.

In order to create a snippets file, go to File -> Preferences -> User Snippets and in the opened invitation select Org that should create a language-specific snippets file called org.json (if you have already created this file before it should be displayed among “Existing Snippets” so you can open and edit it. So as all my time/task management files are stored in one directory I could create a project-specific snippets file (using the “New Snippets file for …” command), but I prefer to store all language specific snippets in one place.

When you have opened this snippets file you would see a brief description how to create user snippets, but you would find more information in the online documentation for this feature.

Year Snippet

Let’s start from the simplest snippet to create a year template. Open org.json file, add the following object entry and save the file:

"Generate Year Template" : {
  "prefix": "_year",
  "description": "Generate Year Template",
  "body": [
    "#+TITLE: $TM_FILENAME_BASE YEAR PLAN",
    "--------------------------------------------------------------------------------",
    "--------------------------------------------------------------------------------",
    "** Health & Sport",
    "* TODO ",
    "* TODO ",
    "",
    "** Career, Business & Work  ",
    "* TODO ",
    "* TODO ",
    "",
    "** Money, Finances & Investments",
    "* TODO ",
    "* TODO ",
    "",
    "** Education & Self-development",
    "* TODO ",
    "* TODO ",
    "",
    "** Friends, Relatives, Colleagues & Other people around",
    "* TODO ",
    "* TODO ",
    "",
    "** Personal life & Family",
    "* TODO ",
    "* TODO ",
    "",
    "** Emotions & Life colorfulness",
    "* TODO ",
    "* TODO ",
    "",
    "",
    "================================================================================",
    "",
    "",
    "#+TITLE: $TM_FILENAME_BASE MID-YEAR RESULTS",
    "--------------------------------------------------------------------------------",
    "--------------------------------------------------------------------------------",
    "",
    "",
    "",
    "",
    "--------------------------------------------------------------------------------"
  ]
},

Now, to create a year template file you need to perform the following steps:

  1. Create a new year file in the directory, e.g., 2020 and name it 2020.org.
  2. Open this file and start typing _year.
  3. This action should activate IntelliSense hint to generate year template.
  4. Select this hint and press Enter. Voila, you have a year template generated.

In this file we use only one variable $TM_FILENAME_BASE that puts the file name in two places into the file name. Thus, it is important to create a file and name it at first, and only then activate the snippet.

Month Snippet

Similarly to year snippet, let’s create month template. Add this object entry to org.json:

"Generate Month Template" : {
  "prefix": "_month",
  "description": "Generate Month Template",
  "body": [
    "#+TITLE: $TM_FILENAME_BASE",
    "",
    "# Week Plan",
    "** GOAL []: ",
    "** GOAL []: ",
    "",
    "*** TODO []: ",
    "*** TODO []: ",
    "--------------------------------------------------------------------------------",
    "# Month Description",
    "GOALS:",
    "  ",
    "TASKS:",
    "  "
  ]
},

The set of actions to activate the month template is the same as for the year snippet, but you have to use the _month prefix in this case.

Week Snippet

The most difficult case is week file. The issue is that I like to know not only the name but also the exact date for each day of a week. However, the issue is that currently VSCode allows to use only regex-based transformation for variables, and I cannot programmatically change the dates. Therefore, I have created two snippets. The first has the fixed names of week days. You can activate this template using the _wn (week names) prefix.

"Generate Week Template with Day Names" : {
  "prefix": "_wn",
  "description": "Generate Week Template with Day Names",
  "body": [
    "#+TITLE: $TM_FILENAME_BASE",
    "",
    "# Week Plan",
    "** GOAL []: ",
    "** GOAL []: ",
    "",
    "*** TODO []: ",
    "*** TODO []: ",
    "--------------------------------------------------------------------------------",
    "--------------------------------------------------------------------------------",
    "**** [MONDAY]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [TUESDAY]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [WEDNESDAY]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [THURSDAY]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [FRIDAY]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [SATURDAY]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [SUNDAY]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "# Metrics",
    "", 
    "WORKING TIME: ",
    "--------------------------------------------------------------------------------",
    "# Week Description:",
    "GOALS:",
    "  ",
    "TASKS:",
    "  "
  ]
},

At the same time, the second uses the [$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_DAY_NAME_SHORT] variables to generate the current date in the Org Mode format and puts it for each day of the week. After the template is generated, you would need to modify the Org Mode context for these dates using the Alt+LeftArrow and Alt+RightArrow hotkeys. You can create this template using the _wd (week dates) prefix.

"Generate Week Template with Dates" : {
  "prefix": "_wd",
  "description": "Generate Week Template with Dates",
  "body": [
    "#+TITLE: $TM_FILENAME_BASE",
    "",
    "# Week Plan",
    "** GOAL []: ",
    "** GOAL []: ",
    "",
    "*** TODO []: ",
    "*** TODO []: ",
    "--------------------------------------------------------------------------------",
    "--------------------------------------------------------------------------------",
    "**** [$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_DAY_NAME_SHORT]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_DAY_NAME_SHORT]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_DAY_NAME_SHORT]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_DAY_NAME_SHORT]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_DAY_NAME_SHORT]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_DAY_NAME_SHORT]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "**** [$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_DAY_NAME_SHORT]",
    "",
    "* TODO []: ",
    "* TODO []: ",
    "",
    "POMODORO: 15m (), 30m (), 45m (), 60m () =",
    "",
    "--------------------------------------------------------------------------------",
    "# Metrics",
    "", 
    "WORKING TIME: ",
    "--------------------------------------------------------------------------------",
    "# Week Description:",
    "GOALS:",
    "  ",
    "TASKS:",
    "  "
  ]
}

All further actions are similar to previous cases.

Final Remarks

If you are reading this post without having a clue on my approach for time/task management it may seem you coming out of nowhere. If you want to understand it you need to read my previous articles on this topic (1, 2, 3). Then, everything would become clear to you.

Of course, these templates are not set in the stone and you can modify them according to your needs. I think that it is quite easy to understand how to do this. If you need more information please refer to the official documentation.

I have also shared the final file with the snippets. You can find it in the accompanying repository.

VSCode snippets is a quite powerful feature that you can use to automate your everyday operations. With the lapse of time, I think Microsoft will make more variables available so that you would be able to create even more powerful snippets. The only feature VSCode snippets currently lacking is a scripting language that can be used for variable transformation (e.g., increase the date by 1 day and get the day name for this date would be very useful for my week template).

Related