目录
1 配置
1.1 launch.json
该配置文件用于存储软件调试配置,常用配置如下:
{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "(gdb) 启动", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/1utest/built/utest.exe", "args": [], "stopAtEntry": true, "cwd": "${workspaceFolder}/1utest/built", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "D:/2Software/MSYS2/usr/bin/gdb.exe", "setupCommands": [ { "description": "为 gdb 启用整齐打印", "text": "-enable-pretty-printing", "ignoreFailures": true }, { "description": "将反汇编风格设置为 Intel", "text": "-gdb-set disassembly-flavor intel", "ignoreFailures": true } ] } ] }
1.2 setting.json
该配置文件用于存储用户个性化配置,常用配置如下:
{ "files.associations": { "totest.h": "c", "cstdint": "cpp", "ota_type.h": "c", "curl.h": "c", "stdio.h": "c", "*.tcc": "cpp", }, "search.exclude": { "**/node_modules": true, "**/bower_components": true, "**/*.code-search": true, // "**/1utest/src/*base": true, // "**/1utest/src/*fix": true, "**/1utest/docs/": true, "**/1utest/result/": true }, "C_Cpp.files.exclude": { "**/.vscode": true, "**/.vs": true, // "**/1utest/src/*base": true, // "**/1utest/src/*fix": true } }
1.3 c_cpp_properties.json
该配置文件用于存储 C/C++ 项目的配置,常用配置如下:
{ "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**", "D:/2Software/MSYS2/usr/lib/**", "D:/2Software/MSYS2/usr/include/**" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "compilerPath": "D:\\2Software\\MSYS2\\usr\\bin\\gcc.exe", "cStandard": "c17", "cppStandard": "gnu++17" } ], "version": 4 }
1.4 user.code-snippets
该配置文件用于存储用户代码片段配置,常用配置如下:
{ // Place your Code 工作区 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. // Example: "add src file header": { "scope": "c,cpp", "prefix": "fh", "description": "add src file header", "body": [ "/**", " * @file ${TM_FILENAME}", " * @authors Nixon (Xinglong.Ni@geely.com)", " * @version 0.1", " * @date ${CURRENT_YEAR}.${CURRENT_MONTH}.${CURRENT_DATE}", " * @brief", " * @note [change history]", " * @copyright GEELY AUTOMOBILE RESEARCH INSTITUTE CO.,LTD Copyright (c) ${CURRENT_YEAR}", " * -------------------------------------------------------------------------", " * [change history]", " * v0.1 ${CURRENT_YEAR}.${CURRENT_MONTH}.${CURRENT_DATE} Nixon 1.初版", " * -------------------------------------------------------------------------", "*/", "", "$0" ] }, "add inc file header": { "scope": "c,cpp", "prefix": "fhh", "description": "add inc file header", "body": [ "/**", " * @file ${TM_FILENAME}", " * @authors Nixon (Xinglong.Ni@geely.com)", " * @version 0.1", " * @date ${CURRENT_YEAR}.${CURRENT_MONTH}.${CURRENT_DATE}", " * @brief", " * @note [change history]", " * @copyright GEELY AUTOMOBILE RESEARCH INSTITUTE CO.,LTD Copyright (c) ${CURRENT_YEAR}", " * -------------------------------------------------------------------------", " * [change history]", " * v0.1 ${CURRENT_YEAR}.${CURRENT_MONTH}.${CURRENT_DATE} Nixon 1.初版", " * -------------------------------------------------------------------------", "*/", "", "#ifndef _${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H_", "#define _${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H_", "", "$0", "", "#endif /* end of _${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H_ */", "" ] }, "add CMakeLists.txt header": { "scope": "cmake", "prefix": "fh", "description": "add file header for cmake", "body": [ "# @file ${TM_FILENAME}", "# @authors Nixon (Xinglong.Ni@geely.com)", "# @version 0.1", "# @date ${CURRENT_YEAR}.${CURRENT_MONTH}.${CURRENT_DATE}", "# @brief $0", "# @note [change history]", "# @copyright GEELY AUTOMOBILE RESEARCH INSTITUTE CO.,LTD Copyright (c) ${CURRENT_YEAR}", "# -------------------------------------------------------------------------", "# [change history]", "# v0.1 ${CURRENT_YEAR}.${CURRENT_MONTH}.${CURRENT_DATE} Nixon 1.初版", "# -------------------------------------------------------------------------" ] }, "add function header": { "scope": "c,cpp", "prefix": "ff", "description": "add function header", "body": [ "/**", " * @brief $0", " * @param", " * @return", " * @note", "*/" ] } }
2 常用快捷键
选中一行: CTRL+L 整体缩进: CTRL+[ / CTRL+] 注释: CTRL+/ 替换: CTRL+H 关闭当前页面: CTRL+W 打开终端: CTRL+` 选中单词: CTRL+D 回退光标的移动和选择: CTRL+U 删除光标前的词: CTRL+BACKSPACE 删除光标后的词: CTRL+DELETE 定位到首行/尾行: CTRL+HOME/END 在单词之间移动光标: CTRL+LEFT/RIGHT 打开文件: CTRL+O 新建文件: CTRL+N 切换打开文件: CTRL+PAGEDOWN/UP 向下插入新行: CTRL+ENTER 向上插入新行: CTRL+SHIFT+ENTER 打开新的软件窗口: CTRL+SHIFT+N 跳转打开文件的各种方法: CTRL+SHIFT+O 跳转到匹配的括号: CTRL+SHIFT+\ 删除行: CTRL+SHIFT+K 在文件所有相同文本内容处,出现光标: CTRL+SHIFT+L 选中光标前后的词: CTRL+SHIFT+LEFT/RIGHT 全局搜索: CTRL+SHIFT+F 全局替换: CTRL+SHIFT+H 连续多列上出现光标: CTRL+ALT+UP/DOWN 选择从光标到行首/行尾的内容: SHIFT+HOME/END 选中多行: SHIFT + UP、DOWN、LEFT、RIGHT 向上、向下复制一行: SHIFT+ALT+UP/DOWN 格式化文档: SHIFT+ALT+F 前进/后退: ALT+LEFT/RIGHT 移动代码行、代码块: ALT+UP/DOWN 选中代码块: ALT+SHIFT+光标 显示命令面板: F1 查找: F3
3 利用VSC获取root权限办法
当自身权限受限(例如在公司虚拟机),无法使用sudo/su获取root权限时,可以采用此办法一试。
执行
sudo code --no-sandbox --user-data-dir=/etc /etc/bash.bashrc
此时在打开的vscode终端,应该已经是root权限,可以开始愉快的修改系统文件了!