I am trying to configure Visual Studio Code (VSC) to compile Project on F7 key. Unfortunately, this IDE does not have a GUI for editing settings like LiteIDE.
I have done the following:
opened a 'hello.go' file in VSC.
pressed Ctrl + Shift + P as mentioned on MS's page.
searched for 'Other' in the list and have not found it.
(?) How I am supposed to use 'Other tasks' which they told me to select?
ok, now I press Ctrl + Shift + B and it says:
"No build task defined. Mark a task with 'isBuildCommand' in the tasks.json file."
I press blue button "Configure build task". It creates folder ".vscode" in my working directory and 'tasks.json' file inside it.
'What the hell are you doing?' - I think. don't make mess in my folder. it is for source files! not for microsoft. ok. let us imagine that we decided to agree with mess in working folder.
in the suggested template, I modify some text and have following 'tasks.json' in the end:
{
"version": "0.1.0",
"command": "go build",
"taskName": "goBuild",
"isShellCommand": true,
"args": [""],
"showOutput": "always"
}
(?) I save the file and try to show list of actions again with Ctrl + Shift + P. I do not see my task in the list. VSC restart does not help. hm.... why is it not in the list?
maybe keybindings will work as I want? File -> Preferences -> Keyboard shortcuts (I am not a maniac to press Ctrl + K and then Ctrl + S, who has created such double hot-..oh..no..it is cold-keys already! XD ).
I click the link to edit .json file manually and add:
// Place your key bindings in this file to overwrite the defaults
[{
"key": "f7",
"command": "workbench.action.tasks.goBuild",
"when": "editorTextFocus"
}]
save, push F7 in editor and...
command 'workbench.action.tasks.goBuild' not found
After using LiteIDE for Go language, in which everything was with 1 click (1 button to build), it seems as VSC was created by aliens for aliens... not for humans as me, at least :(
i'm posting here bc i first tried a visual studio shortcuts for vscode, which didn't include most basic commands.
never understood why microsoft decided to change all defaults for vscode, but if you want to have F7=build, F8=build solution, f5=run, etc...
it's easier than ever to do... just use the built-it keyboard shortcut editor at file -> preferencces -> keyboard
more information and screenshots here
Related
In VS Code, I used to be able to press Command+Shift+E to focus on the file explorer, and then open the currently selected file to edit with Command+Down on Mac... now it doesn't seem to work anymore in the recent VSCode 1.10.2.
I can workaround it by using the mouse/trackpad to doubleclick the file but it's so inefficient compared to the keyboard.
Is there a new keybinding for it?
Version 1.10.0 was the first version to officially support configurable keybindings to the file explorer. I am not sure if the defaults changed in the update. You can now set them to whatever you'd like.
You'll want to add something similar to the following in your keybinding settings:
{ "key": "cmd+shift+e", "command": "workbench.files.action.focusFilesExplorer" },
{ "key": "cmd+down", "command": "list.select" },
More information about the file explorer keybindings in the release docs, or the vscode keybinding documentation page.
I opened few files during coding (both files in project and out project). After that, I close few in its (by ctrl+w and click the 'x' button).
When type ctrl+tab, I always see all opened files.
I try to restart VSCode, restart Windows but nothing change.
How do I close unnecessary files?
I use VS Code 1.0 + Windows 10.
Edit: This feature added in new versions
If you want to clear a specific item (not the whole list) from the recently opened list you have to
Press Ctrl + SHIFT + P
Type Remove From History (in earlier version it is Remove From Editor History) and press Enter
Choose/Find the file you want to clear
Source: link
Update 09.04.2020:
With the release of Visual Studio Code 1.44.0 you can easily remove a file using the UI. You see a closing x next to a file in this recently opened files view:
I could be mistaken but you don't want to delete, but "clear" recently opened files. If that is the case, then follow these steps in regards to VS Code version 1.15.0:
Press Ctrl + Shift + P
Then, within the Quick Open bar, type in >Clear Recently Opened
Press Enter, restart Visual Studio Code, and you should now see nothing under Recent.
Cmd + Shift + P
Clear Editor History
I have just found a workaround which seems to remove a single directory from recents, in case you do not wish to remove all of them.
Press ctrl+shift+p (you may need command+shift+p instead if using a Mac) and select File: Open Recent...
After you click on that, you should see a dropdown with your recently opened projects. Hover with the mouse on the one you want to delete and towards the end of the line you're hovering you should see a small x appearing
Click on that x and you're all done
For latest Visual Studio Code (1.54.2):
View-Command Palette or Ctrl + Shift + P
in the Command Palette dialog box: File: Clear Recently Opened
Restart Visual Studio Code
Press Ctrl + SHIFT + O
You can see recently opened projects and files list
Click the cross icon (X) to remove
After doing some Java I fell in love with some of IntelliJ's features. Especially the keyboard shortcut SHIFT +SHIFT which lets you jump to any other file.
This is a huge time savesaver. Now that I'm back in VS I really miss that feature when I'm editing code. Is there any way to reproduce this in Visual Studio? Perhaps a plugin of some sort?
It's became possible after the recently VS Code release(1.54.0 or above), you can update keybindings.json with following code:
[
{
"key": "shift shift",
"command": "workbench.action.quickOpen"
},
{
"key": "alt alt",
"command": "workbench.action.quickOpen"
},
{
"key": "ctrl ctrl",
"command": "workbench.action.showCommands"
}
]
Source: https://github.com/microsoft/vscode/issues/5280#issuecomment-767869212
Or install VS Code extension: shift shift
No need for ReSharper since Visual Studio 17 has already implemented a similar feature:
CTRL + T
Not exactly the same (doesn't show the last used/opened tabs), but works to jump to a file (might be VS 2013+ only):
CTRL+, then type your search terms, you can use space for different parts of the file name:
con na ex => ControlNameExplorer
I find it easier to use when disabling the Preview Tab (click on the down arrow at the right of the search box to change settings).
More details here.
EDIT
This shortcut is set when installing ReSharper, but you can manually set it to the command Edit.NavigateTo (Tools > Options > Environment > Keyboard).
EDIT for VS2017
The command is now named Edit.GoToAll. Thanks to Matt for pointing it out.
A few years later and ReSharper now has this feature in the latest version.
It's called Search Everywhere/Go to Type and is triggered with shortcut CTRL + N
https://www.jetbrains.com/help/resharper/Navigation_and_Search__Go_to_Type.html
Extremely useful feature, saves you lots of time and allows you to jump to other files while editing code. Once you try it, using Solution Explorer feels like a waste of time. I got used to it while using IntelliJ IDEA & Android Studio, glad it's now available in Visual Studio via ReSharper.
Not really sure what SHIFT-SHIFT does, does that mean holding down both SHIFT keys and pressing J?
I find I seldom need to goto a file. I put my cursor on a variable or a function, hit F12 and it goes to wherever it is defined, without me needing to remember it. If I press SHIFT-F12 it gives a list of every where it is referenced, again without needing to remember. If I want to go back to where I was at I press CTRL+- (which works in any context). I am quite comfortable with this navigation, and so like you, every time I try something new the first thing I do is try to find out how they implement what I am already used to.
The shortcut to Build a solution in Visual Studio 2008 is Ctrl + Shift + B.
I would like to know the default shortcut to Rebuild the solution.
The command Build.RebuildSolution is not bound to any key combination in the standard profiles. However you can use the following trick to invoke it
Alt + B, R
This will navigate to the build menu via Alt + B and then R will select the Rebuild option
Another way is to do this:
Tools >> Options >> Environment >> Keyboard.
Locate the textbox decorated by the 'Show commands Containing' lable.
Type >> 'Build.Rebuild'
Select >> the rebuild type you want, you have two options to choose from.
Locate the textbox decorated by the 'Press shortcut Keys' lable.
Hit >> 'a key on your keyboard', i.e I used F6 for solution wide rebuild.
Click >> the assign button.
CLick >> O.K and to exit.
Finally load up a test project to test out the short cut.
In my installation, there is no default. I am configured for C#, it's possible other configurations will define this by default, but I don't think so. You can see if there is a key assigned by going to Tools -> Customize, clicking the Keyboard... button at the bottom and typing "Build.RebuildSolution" in the Show Commands Containing edit box. If there is a key assigned, it will show up at the bottom of the dialog.
There is no default shortcut to Rebuild Solution.
In addition to the ways mentioned in other answers you can perform the rebuild by
Create a Visual Studio Macro that rebuilds the solution and assign a keyboard shortcut to macro. The advantage of this approach is that you are no longer restricted by the commands provided in visual studio. You can create a custom operation like rebuild the solution, launch the application process and attach the visual studio debugger to the process. All this in a single keyboard shortcut!
I know that Ctrl + Shift + B launches a solution build, but I would like a shortcut that just builds the current project. Is a custom shortcut my only option?
Edit: Looks like a custom shortcut is my only option as Shift + F6 does not work for me.
Assigning the shortcut to "Build.BuildOnlyProject" command doesn't seem to work in VS2008.
Assign the shortcut to "Build.BuildSelection". If you have a solution with several projects and files open from the various projects, whatever file you are currently editing will define the project that will be built when you use the assigned shortcut for "Build.BuildSelection".
You'll know the keyboard shortcut is working when you click the Build menu option and you see the keyboard shortcut on the menu itself.
btw - a restart/reboot is not required when assigning keyboard shortcuts.
custom shortcut depending on what keybindings you are using.....if you look in your menu it will tell you if you have a keybinding.
The other thing I have got used to, because I make use of ViEmu, is use the menu shortcuts. Which are actually quite quick to do, and are independent of bindings.
So to build your project you go Alt + B, U
You can use the shortcuts already established in the main menu that are navigated with the Alt key:
At least for VS2013:
Alt + B, B -> Build Solution
Alt + B, R -> Rebuild Solution
Alt + B, U -> Build current project
Alt + B, E -> Rebuild current project
For some reason after installing Resharper I couldn't get a global shortcut to work (tried several times!!!), but as long as what you want to do is on the main menu, there is always an Alt + "Letter1", "Letter2" combination to trigger whatever action you'd like :-)
For C# development:
F6 or Shift+Ctrl+B - Builds all the projects in the solution.
Shift+F6 - Builds the selected project and its dependencies.
Visual Studio 2015/17
ALT + B + E
ALT + B = Open Build Menu
E = Rebuild Current Project
for C# development. Tools -> Options. Select Keyboard, select additional keyboard mapping scheme to "Visual C# 2005". This mapping has F6 as standard shortcut.
VS 2012 has Shift + F6 already mapped for this. I was surprised to learn this.
For Visual Studio 2017 community, you can use Alt+b then press u to build your current project.
Details: ALT Switch to the main menu -> choose b for build -> u choose the option of build your_project_name from the drop list.
In Visual Studio 2019 this has been set to Ctrl+b
In Visual Studio 2017 and 2019, Shift + F6 works for me.
As Happy Mittal said (Alt + B + J) open a drop window that select the project build, but then i had to press enter instead the last "B" (VS 2017).
In Visual Studio 2015, Alt + B, H will build your solution and publish it.
Sometimes I have to use Visual Studio in a language different than English and the navigation using Alt and a combination of keys is different. If there is someone in the same situation, I found out that is more convenient to create a keyboard shortcut to have consistency among languages. I followed the instructions from https://evanjpalmer.wordpress.com/2013/08/20/build-selection-short-cut-for-visual-studio/ to create the keyboard shortcut:
To set this up:
Tools -> Options -> Environment -> Keyboard (Spanish: Herramientas -> Opciones -> Entorno -> Teclado)
Put the cursor in “Press Keyboard Shortcut Keys” and shift CTRL+SHIFT+B
In Show Commands Containing, type: Build.BuildSelection (Spanish: Compilar.Compilarselección)
Select Build.BuildSelection from the drop down list and hit apply
Put the cursor in “Press Keyboard Shortcut Keys” and shift CTRL+ALT+SHIFT+B
In Show Commands Containing, type: Build.BuildSolution
Select Build.BuildSolutionfrom the drop down list and hit apply
???
PROFIT!
In the Visual Studio options window, under "Keyboard", look for the "Build.BuildOnlyProject" command and you can set whatever you want.
press (Alt + B + J + B) these key combinations to build only current selected project of the solution (VS 2010).
It selects "Build" option from toolbar (Alt + B key ) , then goto "project only" (J key ) and then "Build Only XXX" project (B key).