Use Visual Studio Code

My Visual Studio Code (VSC) usage.

Installation

Download VSC from the official website, and install it with its tips.

Font Settings

Fira Code is a free monospaced font with programming ligatures.
ref: https://github.com/tonsky/FiraCode/wiki/VS-Code-Instructions

Extensions

Simplified Chinese

To use Simplified Chinese UI, install Chinese (Simplified) (简体中文) Language Pack for Visual Studio Code.

Settings Sync

Outdated. It is integrated to VSC.
ref: https://code.visualstudio.com/docs/editor/settings-sync

Material Theme

Material Theme is the official material theme for VSC, while Community Material Theme is a theme maintained by the community with ‘legacy’ color schemes. Material Icon Theme, which provides Material Design Icons for VSC, has far more installers than Material Theme Icons. According to my user experience, Material Icon Theme is also faster.

Background

background can bring background images to your VSC.

Markdown Preview Enhanced

Markdown Preview Enhanced is an extension to write markdown on VSC. ctrl+k, ctrl+v to see the preview. Visit its official website to realize how to use.

Marp for VS Code

Marp for VS Code is a useful extension for making slides in markdown. It can transform md to html, pdf and pptx.

ctrl+alt+win+n (Windows) to start writing a slide deck quickly.

1
2
3
4
5
---
marp: true
---

# Your slide deck

Code Runner

Code Runner is a easy way to run code snippet or code file for multiple languages: C, C++, Java, Python, and so on.

Build C/C++ Environment

This chapter introduces how to build a C/C++ environment on VSC on Windows.

Steps:

  1. Download C/C++ Extension. Open VSC, click Extensions (扩展), or use shortcut ctrl+shift+x. Search C/C++ and download it.
  2. Install MinGW-w64. Install it from the official website of MinGW-w64, or its sourceforge page. Notice: don’t install MinGW.
  3. Change environment virable. If you use win10 or win11, search “env” (环境变量), click Edit the System Environment Variables (编辑系统环境变量), click Advanced (高级) -> Environment Virables... (环境变量), click Path (路径), click new, add the path C:\MInGW\bin\ (change it accroding to your path). Run gcc -v on cmd to know whether you are successful.
  4. Create a C/C++ file. e.g., main.cpp, write some words in it, an example:
    1
    2
    3
    4
    5
    6
    #include <iostream>
    using namespace std;
    int main() {
    cout<<"hello world"<<endl;
    return 0;
    }
  5. Create tasks.json. Click Terminal (终端) -> Configure Tasks..., click g++.exe. Now, select main.cpp, click Terminal -> Run Task, click C/C++: g++.exe build active file. Then a internal terminal will open to show the build result. If successfully, it will create main.exe.
    note: no Chinese characters in path.
  6. Create lauch.json. Click Run (运行) -> Add Configuration....
  7. Now, F5 can start debugging.

refs:

Simple ACM settings

If writing codes in personal computer, may click settings->用户代码片段, create cpp.json, which will save time. Here is a cpp.json example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
"cdf": {
"prefix": "cdf",
"body": [
"#include<bits/stdc++.h>",
"using namespace std;",
"#define lop(i,l,r) for(int i=l; i<r; i++)",
"#define rep(i,l,r) for(int i=l; i<=r; i++)",
"#define per(i,r,l) for(int i=r; i>=l; i--)",
"#define eb emplace_back",
"using ll=int64_t;",
"void solve() {",
"\tint n;cin>>n;",
"\t$0\n",
"}\n",
"int main() {",
"\tcin.tie(0)->sync_with_stdio(0);",
"\tint _; cin>>_;",
"\twhile(_--) solve();",
"\treturn 0;"
"}",
],
"description": "init codeforce model"
},
}

This is to meet the multiple testcases of codeforces. In .cpp file, type cdf and enter, then above codes will be added. But I think the template of Competitive Coding Helper is better.

Clang-Format

Find clang-format.exe, then ./clang-format -style=LLVM -dump-config > .clang-format can generate a .clang-format file. The style can be LLVM, Google, Chromium, and so on.

ref: zhihu: VS Code+Clang-format格式化代码

References

  • 《Visual Studio Code权威指南》