zoukankan      html  css  js  c++  java
  • vscode开发环境整理

    vscode整理

    最近把开发环境从sublime转到了vs code上,sublime被墙真难受,天天和防火墙斗智斗勇,vscode就好一些了。
    vs code主要的还是一些插件与配置,我主要用python和C++,因此主要整理了这两个语言的常用插件。
    PS,不推荐安装中文插件~

    插件

    主题图标

    1. vscode-icons,图标插件
    2. Material Theme, 老牌主题插件
    3. Monokai Dark Vibrant,monokai dark主题,颜色很鲜艳 (推荐)
    4. One Dark Pro, Atom's iconic One Dark theme (推荐)

    代码通用

    1. Code Runner, 支持各种语言的运行(Ctrl+Alt+N
    2. All Autocomplete,从打开文件中生成自动补全
    3. Prettier-Code formatter, 代码规范化
    4. YAML, YAML支持
    5. indent-rainbow, 缩进加强显示,我主要用python,感觉不用也没事
    6. leetcode, 刷题必备

    工具

    1. SFTP, 远程文件同步
    2. Shell,脚本
    3. File Utils, 文件夹相关操作

    markdown

    1. Markdown all in one
    2. markdownlint

    python

    1. Python,必须的
    2. Python for vscode,必须的
    3. Anaconda Extension Pack,使用的Anaconda必备

    C++

    1. C++ 必备
    2. C++ intellisense, 必备
    3. Cmake Tool, 必备

    Git

    1. GitLens
    2. Git History
    3. Git Blame
    4. Git Project Manager

    Latex

    快捷键

    窗口与文件

    1. side bar: Ctrl+B
    2. 打开关闭控制窗口 Ctrl+~
    3. 编辑区打开文件页面切换: Ctrl+Tab,或Ctrl+PageUp, Ctrl+PageDwon
    4. 从控制窗口返回编辑区,Ctrl+Tab选择文件,或者Ctrl+~关闭控制端
    5. 窗口分栏, Ctrl +
    6. 新建文件, Ctrl + N
    7. 打开文件, Ctrl + P
    8. 关闭文件, Ctrl + W
    9. 新建窗口, Ctrl + Shift + N
    10. 关闭在整窗口: Ctrl + Shift + W

    代码与光标

    1. 上下移动页面: Ctrl+(uparrow), Ctrl+(downarrow)
    2. 左右按单词移动光标: Ctrl+( ightarrow), Ctrl+(leftarrow)
    3. 移动到文件开头和结尾: Ctrl + Home, Ctrl + End
    4. 减少/增加缩进: Ctrl + [,Ctrl + [
    5. 选中多个相同字符串同时编辑: Ctrl + D
    6. 代码格式化: ubuntu: Ctrl + Shift + I, win: Alt+Shift+F

    查找与替换

    1. 当前文件查找或替换, Ctrl + F, Ctrl + H
    2. 全局文件查找或替换, Ctrl + Shift + F, Ctrl + Shift + H

    文件配置

    全局文件配置

    在Ubuntu上,全局配置位于~/.config/Code/User/setting.json文件中,我目前的配置为:

    {
        "cmake.configureOnOpen": true,
        "explorer.confirmDelete": false,
        "terminal.integrated.shell.linux": "/bin/bash",
        "editor.suggestSelection": "first",    
        "python.jediEnabled": false,
        "terminal.integrated.inheritEnv": false,
        "gitlens.views.repositories.location": "gitlens",
        "gitlens.views.fileHistory.location": "gitlens",
        "gitlens.views.lineHistory.location": "gitlens",
        "gitlens.views.compare.location": "gitlens",
        "gitlens.views.search.location": "gitlens",
        "workbench.preferredDarkColorTheme": "One Dark Pro",
        "workbench.preferredHighContrastColorTheme": "One Dark Pro",
        "workbench.preferredLightColorTheme": "One Dark Pro",
        "workbench.colorTheme": "One Dark Pro",
        "workbench.iconTheme": "vscode-icons",    
    }
    

    项目文件配置

    项目文件配置位于项目文件夹下的.vscode文件中,主要有

    1. setting.json:项目的配置
    2. task.json:要作用就是执行类似 gcc -g main.c -o main 的命令,用于编译生成
    3. launch.json: 以配置VS Code以在按F5调试程序
    4. sftp.sjon: SFTP模块的配置

    python

    • setting.json
    {
        "python.pythonPath": "/home/willer/anaconda3/bin/python",
        "python.linting.enabled": true,    
        "python.linting.pylintEnabled": false,
        "python.linting.flake8Enabled": true,
        "python.formatting.provider": "autopep8",    
    }
    
    • launch.json
    {
        // 使用 IntelliSense 了解相关属性。 
        // 悬停以查看现有属性的描述。
        // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Python: 当前文件",
                "type": "python",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal"
            }
        ]
    }
    
    • tasks.json
    {   
        "version": "2.0.0",
        "tasks": [
            {
                "label": "python",
                "type": "shell",
                "command": "/home/willer/anaconda3/bin/python",
                 "args": [
                    "${file}"
                ],
                "group": {
                    "kind": "build",
                    "isDefault": true,
                }
            }
        ]
    }
    

    C++

    我用vs code开发C++项目比较少,主要是用Clion。这里可能会有不对的地方。

    • c_cpp_properties.json
    {
        "configurations": [
            {
                "name": "Linux",
                "includePath": [
                    "${workspaceFolder}/**"
                ],
                "defines": [],
                "compilerPath": "/usr/bin/clang-4.0",
                "cStandard": "c11",
                "cppStandard": "c++11",
                "intelliSenseMode": "clang-x64",
                "compileCommands": "${workspaceFolder}/build/compile_commands.json"
            }
        ],
        "version": 4
    }
    
    • launch.json
        // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "program": "${workspaceFolder}/hello", // 修改输出程序路径
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}",
                "environment": [],
                "externalConsole": true,
                "preLaunchTask": "build_hello",           // 添加 "preLaunchTask" 编译任务
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        ]
    }
    
    • task.json
    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "build_hello",  // 与launch的"preLaunchTask"一致
                "type": "shell",
                "command": "make",       // 使用 makefile
                "problemMatcher": {
                    "owner": "cpp",
                    "fileLocation": [
                        "relative",
                        "$workspaceRoot"
                    ],
                    "pattern": {
                        "regexp": "^(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
                        "file": 1,
                        "line": 2,
                        "column": 3,
                        "severity": 4,
                        "message": 5
                    }
                },
                "group": {
                    "kind": "build",
                    "isDefault": true
                }
            }
        ]
    }
    

    SFTP

    {
        "name": "rc",
         "protocol": "sftp",
         "host": "132.XXX.XXX.XXX",
         "username": "root",
         "password": "xxxxxx",
         "port": 22,
         "uploadOnSave": false,
         "downloadOnOpen": false,
         "watcher": {
             "files": "**/*",
             "autoUpload": true,
             "autoDelete": true
         },
         "ignore": [
             "node_modules",
             ".vscode",
             ".idea",
             ".DS_Store"
         ],
         "remotePath": "/www/XXXX"
     
     }
    

    在工作区排除指定文件

    在.vscode/setting.json文件中可以按照如下方式指定排除文件

        "files.exclude": {
            "**/.git": true,
            "**/.svn": true,
            "**/.hg": true,
            "**/CVS": true,
            "**/.DS_Store": true,
            "**/*.db": true,
            "**/datasets": true  
        }
    
  • 相关阅读:
    牛客网-练习题
    牛客网-趋势科技-2020届校园招聘上机考试-1
    976. Largest Perimeter Triangle--Easy
    812. Largest Triangle Area--Easy
    123. Best Time to Buy and Sell Stock III--Hard
    1131. Maximum of Absolute Value Expression--Medium
    1103. Distribute Candies to People--Easy
    满足高并发的I/O Reactor线程模型 (附图,附代码)
    最简洁易懂的方式介绍I/O模型
    从鸿蒙OS的特性看华为应对封锁的策略
  • 原文地址:https://www.cnblogs.com/zi-wang/p/12364097.html
Copyright © 2011-2022 走看看