VSCODE配置C++和Python环境,vscode代码编辑器美化

VSCODE配置C++和Python环境,代码编辑器美化

1.VSCode的下载

官网链接
记得下载.deb格式的

2.编辑器美化

一个好的代码编辑器界面可以看上去更舒服,更有写代码的欲望(bushi
在这里插入图片描述
在Vscode中,点击左下角的小齿轮设置图标,选择设置,然后再点右上角的这三个键中的最左边那个
在这里插入图片描述
就可以修改setting.json了。
安装Fira code字体:参考https://blog.youkuaiyun.com/shkis/article/details/116916274
下面是我的配置文件setting.json,对一些颜色已经做了注释,可以针对性地修改。

{
    "python.pythonPath": "/usr/bin/python2.7",
        "python.formatting.provider": "yapf",
        "files.insertFinalNewline": true,
        "workbench.iconTheme": "Monokai Pro (Filter Machine) Icons",
        "window.zoomLevel": 0.6,

        "files.associations": {
            "*.cjson": "jsonc",
            "*.wxss": "css",
            "*.wxs": "javascript"
        },
        "emmet.includeLanguages": {
            "wxml": "html"
        },
        "minapp-vscode.disableAutoConfig": true,
        "editor.autoClosingBrackets": "always",
        "editor.autoClosingQuotes": "always",
        "files.autoSave": "afterDelay",
        "editor.minimap.enabled": true,
        "breadcrumbs.enabled": true,
        "editor.mouseWheelZoom": true,
        "editor.formatOnType": true,
        
        "git.ignoreMissingGitWarning": true,
        "editor.fontFamily": "Fira code, Consolars, monospace, mononoki,'Courier New'",
        "editor.renderLineHighlight": "none",
        "editor.lineHeight": 18,
        "editor.roundedSelection": false,
        "editor.fontSize": 14,
        "workbench.colorCustomizations": {
            "[Dracula]":{
                "editor.foreground": "#00ffff",
                "editor.selectionBackground": "#696966",                
                "editor.selectionHighlightBorder": "#0aa6ee55",
                "editor.selectionHighlightBackground": "#8bcddd52",
                "editorIndentGuide.activeBackground":"#81868d",
                "editorBracketMatch.background": "#ca9fdb5e",
                "editorBracketMatch.border": "#6b0251",
                "tab.activeBackground": "#ad9cd4b2",
                "textLink.foreground": "#ffee00",
                "descriptionForeground": "#ff0000",
                "selection.background": "#b98cd693",
                "textBlockQuote.background":"#b89a9a",
                "textSeparator.foreground": "#86c2df"

            },
            
            
        },
        "editor.tokenColorCustomizations": {
            "[Dracula]":{
                "comments": "#00f500",
                "strings": "#f6fa00af",
                "functions": "#f6fa04de",   //函数定义
                "keywords": "#f16161",  //关键字,如import、if等
                "variables":"#e5adf1",
                "numbers": "#ffee00",  //数字
                
                
                "textMateRules": [
                    {
                        "name": "Comment",
                        "scope":[
                            "comment"
                        ],
                        "settings": {
                            "foreground": "#1eff005e",  //注释颜色
                            "fontStyle": ""
                        }
                    },
                    {
                        "name": "[VSCODE-CUSTOM] PHP Punctuation Variable Definition",
                        "scope": "punctuation.definition.variable.php",
                        "settings": {
                            "foreground": "#f700ff"
                        }
                    },
                    {
                        "name": "String",
                        "scope":[
                            "string"
                        ],
                        "settings": {
                            "foreground": "#fbff00b0",  //字符串
                            "fontStyle": ""
                        }
                    },
                    {
                        "name": "HTML:Tags",
                        "scope":[
                            "meta.tag",
                            "punctuation.definition.tag.html",
                            "punctuation.definition.tag.begin.html",
                            "punctuation.definition.tag.end.html"
                        ],
                        "settings": {
                            "foreground": "#ffffff",//xml中的尖括号
                            "fontStyle": ""
                        }
                    },
                    {
                        "name": "HTML:Tag Names",
                        "scope":"entity.name.tag",
                        "settings": {
                            "foreground": "#00eaff",
                            "fontStyle": ""
                        }
                    },
                    {
                        "name": "HTML: Attribute Names",
                        "scope": [
                            "meta.tag entity.other.attribute-name",
                            "entity.other.attribute-name.html"
                        ],
                        "settings": {
                            "fontStyle": "",
                            "foreground": "#cc00ff"   //变量
                        }
                    },
                    {
                        "name": "Operator",
                        "scope":"keyword.operator",
                        "settings": {
                            "foreground": "#ffffff",  //运算符
                            "fontStyle": ""
                        }
                    }
                    
                ]
            }
        },
        "python.defaultInterpreterPath": "/usr/bin/python",
        "workbench.colorTheme": "Dracula",
       
}


3.配置C++环境

点击运行-启动调试或者直接按F5会弹出launch.json的设置,之后会跳出task.json,要配置这两个文件,记得保存后就可以运行了。

明确一些概念

单次运行一个脚本视为一个 task,相应的配置文件为 tasks.json,整个文件夹或者多个文件夹视为一个工作空间,配置文件为 settings.json,调试环境的配置文件叫 launch.json,这些配置文件是需要手动编辑的,编辑完保存好就会替代默认的配置文件生效。

launch.json配置
 "version": "0.2.0",
    "configurations": [
        {
            "name": "Python",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config:python.pythonPath}",
            "program": "${file}",
            "cwd": "${workspaceFolder}",
            "env": {},
            "envFile": "${workspaceFolder}/.env",
            "console": "integratedTerminal"
        },
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "build",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
tasks.json配置
 "tasks": [
        {
            "label": "python",
            "type": "shell",
            "command": "python",
            "args": [
                "${file}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "reveal": "always",
                "panel": "shared"
            }
        },
        {
            "type": "shell",
            "label": "build",
            "command": "/usr/bin/g++",
            "args": [
                "-g", "${file}", "-std=c++11", "-o", "${fileBasenameNoExtension}.out"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
setting.json配置
{
    "editor.fontSize": 16,
        "python.pythonPath": "/usr/bin/python2.7",
        "python.formatting.provider": "yapf",
        "files.insertFinalNewline": true
}

  我其实感觉在Vscode中调C++不如直接用终端的Cmake和make命令,因为这样可以更好地理解代码的编译和链接过程,而且反正都是要写CMakelists.txt和package.xml的,直接在文件夹中进行调试反而更直白。

4.Python

这个其实不怎么需要调,保存为.py文件直接运行就ok了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值