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 |
|
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:
- Download C/C++ Extension. Open VSC, click Extensions (扩展), or use shortcut ctrl+shift+x. Search C/C++ and download it.
- Install MinGW-w64. Install it from the official website of MinGW-w64, or its sourceforge page. Notice: don’t install MinGW.
- Change environment virable. If you use win10 or win11, search “env” (环境变量), click
Edit the System Environment Variables
(编辑系统环境变量), clickAdvanced
(高级) ->Environment Virables...
(环境变量), clickPath
(路径), clicknew
, add the pathC:\MInGW\bin\
(change it accroding to your path). Rungcc -v
on cmd to know whether you are successful. - Create a C/C++ file. e.g.,
main.cpp
, write some words in it, an example:1
2
3
4
5
6
using namespace std;
int main() {
cout<<"hello world"<<endl;
return 0;
} - Create
tasks.json
. ClickTerminal
(终端) ->Configure Tasks...
, clickg++.exe
. Now, selectmain.cpp
, clickTerminal
->Run Task
, clickC/C++: g++.exe build active file
. Then a internal terminal will open to show the build result. If successfully, it will createmain.exe
.
note: no Chinese characters in path. - Create
lauch.json
. ClickRun
(运行) ->Add Configuration...
. - Now, F5 can start debugging.
refs:
- https://code.visualstudio.com/docs/cpp/config-mingw
- https://codevoweb.com/set-up-vs-code-to-write-and-debug-cpp-programs/
Simple ACM settings
- Competitive Coding Helper is a good extension to test codes.
If writing codes in personal computer, may click settings->用户代码片段
, create cpp.json
, which will save time. Here is a cpp.json
example:
1 | { |
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权威指南》