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
2 0
Do dạo này Webstorm chẳng hiểu sao lag quá (dù máy mạnh) nên sắc phong Visual Studio Code từ IDE phụ lên IDE chính. Các plugin này để đảm bảo trải ...
Cuong Pham viết gần 4 năm trước
2 0


{{ 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á!