cirry

cirry

我的原生博客地址:https://cirry.cn

Vscode add Markdown Frontmatter code snippet

When using this blog theme, it is recommended to use Vs Code or Obsidian. Both tools can effectively add Frontmatter information to files and support Markdown text writing, as well as Picgo file upload tool.

In my opinion, when writing blogs in markdown, it is essential to automatically generate basic frontmatter. In Vscode, you can choose to use plugins and code snippets to achieve this functionality, each with its own advantages and disadvantages.

Using plugins, you can automatically generate it when creating a new document, but some fields cannot be modified.

Using code, you can customize fields, but you need to use shortcut commands to generate them and manually update the last updated date of the article.

I personally recommend using code snippets without relying on plugins.

Automatically Adding Frontmatter Information in Vscode#

Reference: Snippets in Visual Studio Code

Bottom left corner -> Settings -> Select Add User Snippets

image

Then select New Global Snippets

image

Enter the snippet file name and create the file

{
 "Print to console": {
  "scope": "md,markdown",
  "prefix": "mf",
  "body": [
   "---",
   "title: ${0:$TM_FILENAME_BASE}",
   "date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
   "description:"
   "---"
  ],
  "description": "Log output to console"
 }
}

After configuring, in a markdown file, type mf and press tab to generate frontmatter information.

Others#

More Vscode writing tips: Markdown and Visual Studio Code

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.