Configure VSCode for competitive programming

What is competitive programming?

Sites like CodeForces, TopCoder, HackerRank, CodeChef,... ACM-ICPC, Olympiad in Informatics (for high school students), Google Code Jam, Facebook Hacker Cup,...
Anything involves solving short problems in 2-5 hours by code using algorithms and data structures.


  • High coding speed.
  • One-click compile and run for one source file.
  • Automatic linting
  • C++ (though Java and Python are viable, C++ is still preferable for superior performance).
  • Debugging

Why VSCode?

Lightweight, customizable, familiar to some people (including me), open-source and has an awesome community.


I still haven't been able to figure out how to debug, even after reading VSCode's official guide. So I actually have to use Xcode for (seldom) C++ debugging.


Beware! The instructions below have only been tested on MacOS. I need some volunteers to help me test them on the other OSes.

  1. Setup a C++ compiler of your choice (GCC or Clang). After this step, you should be able to run this command: g++ a.cpp -o a.out && ./a.out or clang++ a.cpp -o a.out && ./a.out
  2. Setup these extensions:
    • C/C++ of course...
    • C/C++ Clang Command Adapter for linting, you can config Clang flags to -Weverything and disable warnings you don't need.
    • Code Runner for one-click compile and run, you should set Code Runner to run in VSCode's integrated Terminal, otherwise it would be impossible to make input.
  3. Set your hotkey for Code Runner, create your snippets and templates, and you are ready to go.

By the way, here is my personal settings:

"code-runner.runInTerminal": true,
"code-runner.executorMap": {
    "cpp": "clang++ -Wl,-stack_size -Wl,0x10000000 -g -Wall -Wextra -pedantic -std=gnu++14 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fstack-protector $fileName -o Executable && ./Executable"
"code-runner.saveFileBeforeRun": true,
"code-runner.preserveFocus": false,
"code-runner.ignoreSelection": true,
"clang.cxxflags": ["-Weverything", "-pedantic", "-std=gnu++14", "-O2", "-Wno-c++98-compat", "-Wno-c++98-compat-pedantic", "-Wno-missing-variable-declarations", "-Wno-missing-prototypes"]

Useful stuff

Bình luận

{{ }}
Bỏ hay Hay
Male avatar
{{ comment_error }}

Hiển thị thử

Chỉnh sửa


Nguyễn Lê Vũ Long

1 bài viết.
14 người follow
{{userFollowed ? 'Following' : 'Follow'}}
Bài viết liên quan
Male avatar
0 0
Constructor của lớp cha luôn được gọi trước constructor của lớp con. class Foo { public: Foo() { cout << "Base class initializing" << endl; ...
phqb viết gần 4 năm trước
0 0
11 1
Chức năng pattern matching trong C++ thấy nói sẽ kill (Link). Cách viết C++ do vậy sẽ thay đổi tương đối. Tự nhiên tôi thấy phải nhìn lại visitor ...
cpplover viết hơn 5 năm trước
11 1


{{ comment_count }}

bình luận

{{liked ? "Đã kipalog" : "Kipalog"}}

{{userFollowed ? 'Following' : 'Follow'}}
1 bài viết.
14 người follow

 Đầu mục bài viết

Vẫn còn nữa! x

Kipalog vẫn còn rất nhiều bài viết hay và chủ đề thú vị chờ bạn khám phá!