美文网首页开发工具
Vscode C++开发插件整理

Vscode C++开发插件整理

作者: DayDayUpppppp | 来源:发表于2019-09-20 17:36 被阅读0次

用vscode开发了一段时间,整理一下用到的一些配置和一些提供开发效率的插件。

1. 配置
  • vscode自动识别猜测编码方式:

      "files.autoGuessEncoding": true,
      "[c]": {
          "files.encoding": "gbk"
      },
      "[cpp]":{
          "files.encoding": "gbk"
      },
      "files.eol": "\n",
    
  • 视图, 字体,tab方面的配置:

      //VSCode自带的小地图太宽
      //写代码时太占用可编辑区域可以调小
      "editor.minimap.maxColumn": 40,
      
      // tab = 4 空格,以及显示tab 
      "editor.fontSize": 15,
      "editor.detectIndentation": false,
      "editor.tabSize": 4,
      "editor.renderControlCharacters": true,
      "editor.renderWhitespace": "all",
      "editor.fontFamily": "Consolas, 'Menlo', Menlo",
      "editor.formatOnPaste": false,
      "editor.lineHeight": 24,
    
  • 文件栏显示去掉特定的文件

      "files.exclude": {
          "**/.git": true,
          "**/.svn": true,
          "**/.hg": true,
          "**/CVS": true,
          "**/.DS_Store": true,
          "**/.vscode": true,
          "GPATH": true,
          "GRTAGS": true,
          "GTAGS": true,
          "**/*.o": true,
          "**/*.lo": true,
          "**/*.la": true,
          "**/*.al": true,
          "**/*.libs": true,
          "**/*.so": true,
          "**/*.so.[0-9]*": true,
          "**/*.a": true,
          "**/*.pyc": true,
          "**/*.pyo": true,
          "**/*.d": true,
          "**/*.gch": true,
          // "**/*.log": true,
          // "**/*.log.[0-9]*": true,
          // "**/*.error": true,
          // "**/*.error.[0-9]*": true,
          "**/*.swp": true,
          "**/*.std.out*": true,
      },
    
  • 搜索的时候排除掉特定的文件

      "search.exclude": {
          "**/.vscode": true,
          "**/node_modules": true,
          "**/bower_components": true,
          "**/.svn": true,
      },
    
  • 配置代理

    "http.proxy": "http://xxxx:8080",
    
2. 快捷键
  • 常用快捷键
    ctrl + p   #模糊搜索整个项目的文件
    ctrl + shift + p (F1)    # 全局的配置命令的执行 
    
    Alt  + ← (方向箭)  # 在函数的调用关系之间前进或者后退
    ctrl + k, ctrl + 1    # 函数折叠
    ctrl + g              # 跳转到文件的第多少行
    
  • 特别方便的快捷键:
    ctrl + shift + o      # 列出当前文件的所有函数符号名
    ctrl + tab            # 在最近的打开的几个文件之间跳转
    

vscode全部的快捷键

3. 插件
  1. c++ 开发必备插件: C/C++ for Visual Studio Code

  2. Bracket Pair Colorizer

    这个插件可以把代码里面的括号用不同的颜色标记出来,开发起来就不用担心括号不匹配了,非常方便。 image.png
  3. Indenticator

    代码缩进用颜色标记出来,我太喜欢这个插件了。
  4. bookmarks
    代码上面打书签,ctrl + shift + k,打标签。

  5. sftp
    日常的开发环境是window下面写代码,linux上面跑。sftp插件可以方便的把代码同步带remote的linux机器上面。
    第一步,创建一个工作区。里面的配置是空的(这样从remote远端会把代码同步过来。)

    第二步,安装插件之后,第一步,F1,输入配置。 配置文件:
    {
    "name": "dev-remote-trunk3",
    "host": "10.xxx.xxx.130",
    "protocol": "sftp",
    "port": 36000,
    "username": "xxx",
    "password": "xxx",
    "remotePath": "/data/home/xxxx/trunk3/qss/src",
    "uploadOnSave": true,
    "ignore": [
        "\\.vscode",
        "\\.git",
        "\\.DS_Store",
        "\\.svn",
        "\\.history",
        "\\*.o",
        "\\*.gch",
        "**/dependencies/**"
    ]
    }
    
第三步,开始同步。
  1. 安装gnu global
    配置好环境变量之后,在相应的代码目录下面执行gtags。(window下面)


    image.png
image.png

这样会建立相应的符号表,可以进行符号的搜索。

安装插件:Fuzzy Tag For C/C++
组里面的大佬自己开发的插件。大佬吐槽vscode不支持模糊的函数解析,于是自己写了一个。F10,可以模糊查找函数。这个太方便了,在开发的时候,很多函数名记得不是很清楚,只能模糊搜索,这个插件非常方便。

  1. C/C++

    C/C++ 插件在0.24.1的版本之后,查看引用就不是基于gtags了,而是改为自用的。在比较大的项目中,查看引用的速度就会变慢很多。可以改用这个版本的C/C++插件,非常好用。 image.png

相关文章

网友评论

    本文标题:Vscode C++开发插件整理

    本文链接:https://www.haomeiwen.com/subject/owljuctx.html