文本编辑 Visual Studio Code


原文链接: 文本编辑 Visual Studio Code

配置C/C++交叉编译环境

.vscode/c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "macFrameworkPath": [],
            "compilerPath": "/usr/local/bin/gcc-9",
            "cStandard": "gnu18",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x64"
        },
        {
            "name": "arm-linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/Volumes/linux/x-tools/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/7.4.0/../../../../arm-none-linux-gnueabi/include/c++/7.4.0",
                "/Volumes/linux/x-tools/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/7.4.0/../../../../arm-none-linux-gnueabi/include/c++/7.4.0/arm-none-linux-gnueabi",
                "/Volumes/linux/x-tools/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/7.4.0/../../../../arm-none-linux-gnueabi/include/c++/7.4.0/backward",
                "/Volumes/linux/x-tools/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/7.4.0/include",
                "/Volumes/linux/x-tools/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/7.4.0/include-fixed",
                "/Volumes/linux/x-tools/arm-none-linux-gnueabi/lib/gcc/arm-none-linux-gnueabi/7.4.0/../../../../arm-none-linux-gnueabi/include",
                "/Volumes/linux/x-tools/arm-none-linux-gnueabi/arm-none-linux-gnueabi/sysroot/usr/include"
            ],
            "browse": {
                "path": []
            },
            "defines": [
                "__KERNEL__"
            ],
            "compilerPath": "/Volumes/linux/x-tools/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc",
            "compilerArgs": [
                "-cpu=cotexA7"
            ],
            "cStandard": "gnu99",
            "cppStandard": "c++11"
        }
    ],
    "version": 4
}

– Visual Studio Code 的 Docker 插件

Atom One Dark Syntax Theme
Running Visual Studio Code on Linux

vscode 内置变量

https://code.visualstudio.com/docs/editor/variables-reference

Predefined variables

${workspaceFolder} - the path of the folder opened in VS Code
${workspaceFolderBasename} - the name of the folder opened in VS Code without any slashes (/)
${file} - the current opened file
${relativeFile} - the current opened file relative to workspaceFolder
${fileBasename} - the current opened file's basename
${fileBasenameNoExtension} - the current opened file's basename with no file extension
${fileDirname} - the current opened file's dirname
${fileExtname} - the current opened file's extension
${cwd} - the task runner's current working directory on startup
${lineNumber} - the current selected line number in the active file
${selectedText} - the current selected text in the active file
${execPath} - the path to the running VS Code executable
Predefined variables examples
Supposing that you have the following requirements:

A file located at/home/your-username/your-project/folder/file.ext opened in your editor;
The directory /home/your-username/your-project opened as your root workspace.
So you will have the following values for each variable:

${workspaceFolder} - /home/your-username/your-project
${workspaceFolderBasename} - your-project
${file} - /home/your-username/your-project/folder/file.ext
${relativeFile} - folder/file.ext
${fileBasename} - file.ext
${fileBasenameNoExtension} - file
${fileDirname} - /home/your-username/your-project/folder
${fileExtname} - .ext
${lineNumber} - line number of the cursor
${selectedText} - text selected in your code editor
${execPath} - location of Code.exe
Tip: Use IntelliSense inside string values for tasks.json and launch.json to get a full list of predefined variables.

vscode 忽略目录

When you see this notification, it indicates that the VS Code file watcher is running out of handles because the workspace is large and contains many files. The current limit can be viewed by running:

cat /proc/sys/fs/inotify/max_user_watches

The limit can be increased to its maximum by editing /etc/sysctl.conf and adding this line to the end of the file:

fs.inotify.max_user_watches=524288

The new value can then be loaded in by running sudo sysctl -p. Note that Arch Linux works a little differently, view this page for advice.

While 524288 is the maximum number of files that can be watched, if you're in an environment that is particularly memory constrained, you may wish to lower the number. Each file watch takes up 540 bytes (32-bit) or ~1kB (64-bit), so assuming that all 524288 watches are consumed that results in an upper bound of around 256MB (32-bit) or 512MB (64-bit).

Another option is to exclude specific workspace directories from the VS Code file watcher with the files.watcherExclude setting. The default for files.watcherExclude excludes node_module and some folders under .git but you can add other directories that you don't want VS Code to track.

"files.watcherExclude": {

"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true

}

`