简体   繁体   中英

How to define a keyboard shortcut for building the default project in VC++ IDE?

The Visual Studio for C++ defines a keyboard shortcut F7 for building the whole solution. However, it doesn't define a keyboard shortcut for building the default project.

Usually, a solution contains many projects and one of the projects is defaulted. If I modified some code in the default project and want to build it, I must use the mouse to right-click the project name, and select the 'build' menu. It's slow and tedious.

Is there a way to define a keyboard shortcut such as F4 for building the default project?

In VS2013, I needed to use the Command Build.BuildSelection instead of Build.BuildOnlyProject .

在此输入图像描述

You don't specify which version of Visual Studio you have, but in VS2012, you can certainly create a keyboard shortcut to build the current project.

Choose Tools/Options from the menu, and then select Keyboard from the Environment section and locate the required action to assign whatever keyboard shortcut you like:

建立

Just click in the Press shortcut keys box and press the key combination you require.

Having said that, it's normal for a Solution to contain related Projects, and for some or all of these projects to have dependencies, for example a static lib and a consuming executable. As long as all the other projects in the solution are already built, pressing F7 to build the solution will only build what is necessary based on what you have changed. So there should be little overhead in doing so.

If your solution has grouped projects for a different reason (eg as part of a larger build), you can always create a separate solution that just contains a single project and then use F7 without having to make a keyboard shortcut.

In VS 2013, in the BUILD menu, you should see the Build Selection section after the Build Solution section. You will see that Shift+F6 is already assigned to Build ErrorHandler , the default project.

构建菜单

You can also add the Build toolbar. The first button on it should be the Build Selection button.

构建工具栏

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM