How to use VSCode for writing compiler commands

Complier Commands

Simplify writing compiler commands


While learning C/C++ I found that writing the compiler commands for the terminal is tedious job especially if you write many files. To simplify this process you can use the snippets of vscode.


The steps are as follows:

  1. Open the command palette
  2. Enter Configure User Snippet
  3. Select the language for which you would like to configure your the snippets, I choose C
  4. A .json File will open and you can configure your snippets for all C programms
  5. For writing the compiler commands I use the following snippet:
   "compile_pthread": {
		"prefix": "comp",
		"body": [
		"description": "Create compiler commands"

With the prefix comp I can write the compiler command for a specific c file. With the variable $LINE_COMMENT I create a line comment, $TM_FILENAME_BASE takes the file name and $TM_FILENAME is the full file name e.g. programm.c. I included the -lpthread option as I currently study parallel programming.