How to add a shortcut for "Launch the selected target in terminal window" button? - visual-studio-code

I use Visual Studio Code and the CMake extension (twxs.cmake). The extension integrates CMake to vscode. There is a button which allows us to run a target in terminal window. It looks like a play button. .
My question is, how can I add a keyboard shortcut for this button? I cannot find the action name so I cannot link it. I wish to use keyboard shortcut instead of clicking that button every time.
I tried googling the action name of this button so I could bind it with any keyboard shortcut, but I couldn't find anything.
Any help will be appreciated.
Thank you in advance!

Shift+F5 appears to do the same thing as clicking that button.
I found the following here:
Running Targets Without a Debugger
Sometimes one will want to just run a target and see its output. This
can be done with the CMake: Execute the current target without a
debugger command, or the associated keybinding (the default is
Shift+F5).
The output of the target will be shown in an integrated terminal.

Related

Missing Run And Debug Launch Configuration button in VS Code

I have the following situation.
I cannot change launch Dart configurations anymore since the button is missing.
I think I hid it by accident but I cannot make it appear anymore.
Launch.json is still accessible but the button has disappeared.
Any help is appreciated, I don't really want to reinstall VS Code and I don't think it would help.
An alternative, if anyone else is facing this: If you right-click the gear and check "Start debugging" then that should bring it back. Despite the name, it won't actually start a debugging session!
I've found out how to restore the button's position.
Type the keyboard combination to start a Command (e.g.Command + Shift + P on MacOS) and run the command View: Reset All Menus.
This'll make the hidden view reappear.
The option to hide it is called Hide 'Start Debugging' and it cannot be found in the settings, so you have to reset the views to make it reappear.
if resetting the menu from command option by pressing: Ctrl + Shift + P and typing the command View: Reset All Menus may work. In case it didn't I suggest you to open a seperate command line i.e CMD or Terminal in VS Code itself then typing the command Flutter Run may help. Also you can press in the terminal R to hot reload your flutter, dart app.

Disable the "refactor preview" confirmation tab

A few weeks ago, refactoring code using F2 worked without any confirmation. Since a few days, however, using F2 opens up a "Refactor preview" tab in the bottom panel.
The refactoring will not be done until I manually check what I want to refactor, and click the checkmark at the top right.
I cannot find anything online or in the vscode settings. Can this be disabled so that the refactoring automatically proceeds like it used to?
Are you accidentally pressing Shift + Enter after renaming?
This behavior should only happen after you press F2, change the name of the item, and then press Shift + Enter. Pressing only enter should automatically perform the rename without the refactor preview tab opening. The rename box states this:
In case its not clear, here is a video that illustrates this.
Note: This solution is only for c/c++ case. The reason is that C/C++ extension is doing bad in analyzing the code and relies on user to determine which ones to rename, then the preview panel is poped up for this.
Try disable Editor > Rename: Enable Preview in settings, and then restart vscode.
If the problem still exists, try replace C/C++ extension's intellisense with clangd:
Install clangd extension in vscode;
Disable C/C++ extension's intellisense by adding this to settings.json:
"C_Cpp.intelliSenseEngine": "Disabled"
Then vscode will adopt clangd's intellisense, which renames without a preview.
Uninstalling C/C++ extension is NOT recommended because intergrated gdb will be lost, but you can try lldb as a substitude:
Install CodeLLDB extension in vscode;
Configure cmake's default debug type to lldb in settings.json:
"cmake.debugConfig": {
"type": "lldb"
}

How show button to run current file in Visual Studio Code

Recently, in one of my Visual Studio Code instances, now there is a green "play" button that allows me to Run Python File in Terminal.
You can see that button in the picture below, just between the "open changes" and the "split editor" buttons.
I have Visual Studio code installed in other computers, and there is no such button. I would like to show that button since it comes very handy, but I do not know how to make that happen, and I cannot find any documentation.
Note: I'm not using any extension for running files
The 'Play' button feature is in testing at the moment, and so is only available to those in the experiment group.
https://github.com/microsoft/vscode-python/issues/5321
Having said that, I had the button appear yesterday part way through a session.
Unfortunately, today the button is no longer present, and I am not part of the experiment group.
Install Code Runner simple by press (Ctrl+shift+X) and search for "Code Runner",it works for almost all languages including python. it gives you a button and shortcut Ctrl+Alt+N.
This area is called "Editor Actions". It's now available by default but unfortunately cannot be hidden unless you modify stylesheet:
https://github.com/Microsoft/vscode/issues/46403

How to run the select code in VScode?

I want to run the select code of python in VScode. Till now, I have to copy the code and paste it in the terminal below to run. The system is mac OS.
So is there any way to run the code directly after I selected the code? For example, like the shortcuts.
Thanks.
There is no default keybindings for command "Run Selected Text in Active Terminal", but you can create one.
Press Ctrl+K, Ctrl+S to open File → Preferences → Keyboard Shortcuts.
Search for workbench.action.terminal.runSelectedText in keybindings.
Press the icon on the left to open a windnow with this message "Press desired key combination..." and make your choice. (I've pressed Ctrl+Alt+R - as this combination was not used yet.)
Press Enter to store your keybinding.
Tested on VSCode 1.30.2 on Windows 10 Pro.
#yanachen, this is now possible in VS Code. All you need to do is:
1. Ensure python is running in the VS Code terminal window
2. Select the text you wish to execute in python
3. Invoke the command 'workbench.action.terminal.runSelectedText' as defined in the following link:
https://code.visualstudio.com/docs/editor/integrated-terminal#_key-bindings
Now it's supported by default shortcut "shift" + "enter".
select the proper code snippet
press "shift" + "enter"
Here is the setting for running selection in "interactive window."
In my VS Code (version 1.56.2), I do the following things: go to Settings, search for interactive window, in the resulting left panel choose Jupyter, and finally check the box next to Jupyter: Send selection to interactive window. That's it. One more step for some users (including me) is to modify the keybinding for running selection to your preference. For example, got to keyboard shortcuts, type run selection, you should see a list of keybindings and you may need to redefine them if conflicts exist.
Some language specific extensions have already an existing keybinding.
On Windows, for the PowerShell extension it is currently F8 to run the selected text.
Install the vscode extension Node.js Exec. then select the block of code you want to run and press f8. worked for me.

Choose-Command popup in Eclipse

I would like to ask if there exists some functionality in eclipse where it's possible to choose all available commands, instead of having to remember all the shortcuts.
Something like the command palette in sublime text 2. Where you by pressing ctrl+shift+p (windows/linux) get an input popup box where all availble commands can be choosen.
Does such a feature exists for eclipse, or should I develop it by myself?
Thanks in advance.
I just bumped into this feature by accident but looking up to see if I figure how to get to it. it looked like it popped up when I started typing after having launched eclipse without focusing on any particular view... more to come as soon as I find out for sure.
EDIT: Apparently when you first launch Eclipse the focus is on the "Quick Action" search box on the top right of the tool bar and that's where you can start typing command names for it to list and let you pick in good Sublime Text style. Not sure how to shortcut into the box other than clicking it, but apparently there's the feature.
EDIT#2: http://www.vogella.com/tutorials/EclipseShortcuts/article.html#shortcuts_overview describes Ctrl+3 as being the shortcut to get there, on the Mac it translates to Cmd+3.
I haven't been able to find anything, so I have started on developing my own plugin.