Use Visual Studio Code
My Visual Studio Code (VSC) usage.
Installation
Download VSC from the official website, and install it with its tips.
Custom Settings
Fira Code is a free monospaced font with programming ligatures.
ref: https://github.com/tonsky/FiraCode/wiki/VS-Code-Instructions
Extensions
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, JavaScript, PHP, 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. To use Simplified Chinese UI, you can install Chinese (Simplified) (简体中文) Language Pack for Visual Studio Code.
- 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
. - 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
If you are a ACMer, Competitive Coding Helper is a good extension to test your codes.
If you write codes in your computer, you can click settings->用户代码片段
, create cpp.json
, which will efficiently save your time. Here is a cpp.json
example:
1 | { |
Then prt(n)
can replace cout<<n<<'\n'
, rep(i,a,b)
can replace for(int i=a;i<b;i++)
, and so on. Specifically, I establish a structure of while(t--) solve()
to adapt to the testcases of codeforces. Type cdf
and Enter, it will add above codes to your .cpp
file.
Clang-Format
Use Everything to 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, Mozilla, WebKit.
ref: zhihu: VS Code+Clang-format格式化代码
References
- 《Visual Studio Code权威指南》