1、簡介
VSCode 全稱 Visual Studio Code,是微軟出的一款輕量級代碼編輯器,免費、開源而且功能強大。內置JavaScript、TypeScript和Node.js支持,而且擁有豐富的插件生態系統,可通過安裝插件來支持C++、C#、Python、PHP等其他語言。
2、軟件下載安裝
下載地址:https://vscode.en.softonic.com/download
安裝步驟不詳細講解了,無腦下一步即可。
3、擴展插件安裝(快捷鍵 ctrl+shift+x)
3.1、配置中文菜單
Vscode默認爲英文菜單,英文用不慣可以在插件商店中搜索chinese,安裝中文語言包,重啓vscode即可生效。
3.2、配置主題
一個好的主題,能夠大大提高我們的編碼效率。推薦配置Tiny Light主題,推薦理由:護眼,抗疲勞。
3.3、安裝C/C++插件支持
安裝C/C++和C++ Intellisense,用於C/C++智能感知功能(跳轉、代碼補全功能等)。
3.4、安裝git插件
雖然vscode內置git版本控制,但是安裝插件GitLens後功能會更加強大。
3.5、安裝doxgen插件
doxgen工具能夠根據代碼註釋生成文檔,我們只需在寫代碼時將註釋安裝doxgen要求的格式寫好即可,該插件能夠幫助我們更快捷、方便的書寫doxgen風格的註釋。
4.配置用戶代碼片段 (自定義代碼補全)
快捷鍵ctrl+shift+P顯示所有命令,輸入snippets,配置用戶代碼片段。
比如頭文件的自動補全,輸入#ifndef,直接補全後面的內容,則需新建全局代碼片段json配置文件。
配置文件內容如下所示:
{
// Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
"C header file": {
"prefix": "#ifndef",
"body": [
"#ifndef __$1_H__",
"#define __$1_H__",
"",
"#ifdef __cplusplus",
"extern \"C\"{",
"#endif /* __cplusplus */",
"",
"",
"",
"",
"",
"#ifdef __cplusplus",
"}",
"#endif /* __cplusplus */",
"#endif /* __$1_H__ */"
],
"description": "C header file define"
}
}
配置完成後保存,重啓vscode。使用效果如下圖所示:
如上所示,大家可以自定義屬於自己的代碼片段,功能可以說是十分強大。
Vscode的功能遠不止於此,還需自己以後慢慢挖掘。