本文介绍了如何在Visual代码编辑器中准备/配置C ++项目的开发环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JavaScript项目使用nodejs和可视化代码编辑器。我想知道是否可以为C ++项目配置这样一个伟大的代码编辑器。

I'm working with JavaScript projects using nodejs and visual code editor. I wonder is it possible to configure such a great code editor for C++ projects.

我想链接调试器,并建立一些热键建立调试/发布版本的项目。

I want to link the debugger and make some hotkeys for building the debug/release versions of project.

是否可能为C ++项目和我应该/读取它? b $ b

Is it possible for C++ projects and what should I do/read for it?

推荐答案

这是目前不可能的,直到有一个公开的扩展API可用。我期望它今年11月或12月。

This is currently not possible until there is a public extension API available. I expect it to come in November or December this year.

如果只有一个项目要在工作区中编译,您可以立即执行。
这是怎么做的:

You can do it right now if there is only one project you want to compile in your workspace. This is how to do it:


  • 在VSCode中打开项目的根文件夹(这是你的工作区) li>
  • 在接受值为 release / debug 的参数的工作空间中放置一个批处理/ shell脚本,并在发布或调试中编译项目 在工作区中没有 .vscode 目录的情况下, li>
  • 向包含此内容的文件夹中添加一个文件 tasks.json

  • Open the root folder of your project in VSCode (this is your workspace)
  • Place a batch/shell script in the workspace that accepts a parameter with a value of release/debug and compiles the project in release or debug mode depending on the passed parameter value
  • In case there is no .vscode directory in the workspace then create it on your own
  • Add a file tasks.json to that folder having this content:

{
  "version": "0.1.0",
  "command": "${workspaceRoot}/CompileProject.bat",
  "tasks": [
     {
          "taskName": "Compile debug build",
          "args": [
            "debug" 
          ],
          "isTestCommand": true            
     },
     {
          "taskName": "Compile release build",
          "args": [
            "release" 
          ],
          "isBuildCommand": true            
     }         
  ]
}


您可以使用 CTRL + Shift + T 触发编译调试版本 code>和使用 CTRL + Shift + B 编译版本构建

You can trigger Compile debug build with CTRL + Shift + T and Compile release build with CTRL + Shift + B.

您可以通过转到 File - >来更改键盘绑定。偏好设置 - >键盘快捷键,并为命令 workbench.action.tasks.test workbench.action.tasks定义首选快捷方式。构建
示例:

You can change the keybindings by going to File -> Preferences -> Keyboard Shortcuts and define your preferred shortcuts for the commands workbench.action.tasks.test and workbench.action.tasks.build.Example:

[
    { "key": "f5",          "command": "workbench.action.tasks.test" },
    { "key": "f6",          "command": "workbench.action.tasks.build" } 
]

这篇关于如何在Visual代码编辑器中准备/配置C ++项目的开发环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 23:00