DEV Community

5hfT
5hfT

Posted on • Updated on

Make Competitive Programming Easy with VS Code

Make Coding Easy

This tutorial is for linux (debian based) only

If you are a windows user then check this out Setup VS Code for windows

1. VS code task config to make competitive programming easy and programme ananlysis !

This is a .json file which will help you to run your cpp file with one click or shortcut.
In this case , you don't need to write input in the command line or write fopen / close stuffs , programme will take input from a file (input.txt) automatically and give the output in another file (output.txt) .



You can also find the programme runtime status which will help you to calculate execution time as well as memory usage and many more !

pre-requirments :

  • Visual Studio Code
  • gcc/g++
  • time
    • install time : sudo apt install time

More things to do :
Note : You just need to do these things only for the first time of your workspace!

  • Split screen in 3 sections
    • split the main section in right (right mouse click on the .cpp file and u will get the split options)
    • then split the right into down (same as above)
  • create a file named input.txt
  • create a file named output.txt
  • open input.txt into the upper right section
  • open output.txt into the lower right section

This will be the final look of your vs code

How to setup :

  • Go to Configure Default Build Task...
    • In Menu bar
      • Clik on terminal (At the top)
    • select configure task
    • select create task.json from template (this will create a task.json file in .vscode in your working directory)
    • select other and new task.json file will be created
    • now copy and paste the my task(cpp).json {link is here} file into your task.json file
    • done

Usage :

  • Run :
    • Shortcut type : ctrl+shift+b
  • You nee to give the input in the input.txt file
  • output will be shown in the output.txt file
  • ##### Bonus : programme status will be shown in the sys.txt file
  • people concern about more details such as binary form and disassemble code can check tasks(more).json file

2. VS CODE Snippet :

This one is made for my personal usage ,you can add functions as you wish and edit my name and doc

  • Download the cpp.json file
  • Select User Snippets under File > Preferences (Code > Preferences on macOS), and then select cpp.json
  • copy or replace the cpp.json file with downloaded file and save !

Happy Coding with VS Code

You can check my git repo VS-Code-Config

I have added some more files for python too !

Top comments (6)

Collapse
 
jagannath123 profile image
jagannath-123

can you please tell me how to setup task(cpp more).json file which you have give in your github .

Thank you in advance

Collapse
 
mh_shifat profile image
5hfT
  • Clik on terminal (At the top)
  • select configure task
  • select create task.json from template (this will create a .json file in .vscode folder inside your working dir)
  • select other and new task.json file will be created
  • now copy and paste the my task.json file into your task.json file
  • done
Collapse
 
mh_shifat profile image
5hfT

I have updated the post for easy understanding . Thanks for checking!

Collapse
 
arihant416 profile image
Arihant jain

Wow shifat thanks man !! this will definitely make things alot easier for me now. Appreciate it.

Collapse
 
mh_shifat profile image
5hfT

most welcome

Collapse
 
erenyaeger profile image
Eren Yaeger

It's not working on my vscode, since I already follow your steps still not working.. Please help me.....