MacOS keybindings not overriden inside VS Code debugger? - python

I'm currently using VSCode Version 1.28.2 (1.28.2). When I use the integrated debugger, I find that the F11 key (whose purpose is to step into a function) does not override the MacOS (Sierra 10.12.6) default behaviour (show Desktop). I'm currently bypassing the issue by disabling the shortcut on my Mac, but this seems like a sub-par fix. Is there a better way?

Hold down the fn key when you press F11 and it will then act as F11 and not "Show Desktop".

Try Fluor. It can automatically enable the Function keys depending on the current application in view.
This lets you use F11, and other function keys in VS Code while automatically switching back to the default functions when in other apps.

For MacOS:
Go to System Preferences -> Keyboard -> Shortcuts and uncheck the "Show Desktop F11" option inside one of the submenus (Mission Control).
This worked for me on
Catalina 10.15.7

Related

Spyder : how to make completion and documentation pop-up windows appear only on command

I am using Spyder 4.0.1, and when I code windows with documentation/completions like the one below pop-up constantly. It's very distracting. However they do remain very useful when I need them!
So how can I configure spyder so that they ONLY appear when I press a macro/hotkey combination (instead of popping up unsolicited all the time)?
By the way I deactivated these windows by going to:
"preferences/completion and linting/completion" and unticking:
Show completion details
Show completions on the fly
"preferences/completion and linting/advanced" and unticking:
enable Kite
enable fallback completions
EDIT
As explained by Carlos Cordoba, activating "enable fallback completions" on its own enabled did not bring any pop-up windows unless I pressed Ctrl + Space. Perfect !
However "enable Kite" on its own makes the following windows pop-up as soon as I type a function name:
Maybe I did something bad in my setup?
(Spyder maintainer here) You don't need to deactive these options:
Enable Kite
Enable fallback completions
to get what you want. That's because by deactivating Show completions on the fly, completions will only be shown when pressing Tab or Ctrl + Space. Note: Several errors with fallback completions, and completions in general, will be fixed in our 4.1.0 version, to be released later in March 2020.
However, you need to deactivate the option called Enable hover hints (present in Preferences > Completion and linting > Introspection) to disable the extra information bubbles displayed in your first screenshot above. Unfortunately, there's no shortcut to show them at will because they depend on the mouse position.
Besides, to hide the bubbles shown after typing an open parenthesis (as displayed in your second screenshot), you need to deactivate the option called Show calltips (also present in Preferences > Completion and linting > Introspection).

How to move caret to console in pycharm?

Is it possible to have a keyboard shortcut to move the caret from editor to console and back in pycharm? I can switch the focus between editor and console using CTRL+TAB, but that doesn't allow me to start typing in the console unless I click in it.
I am using the linux community distribution.
I'm on MacOS and PyCharm 2018.2. Doing Ctrl+Tab+P opens up console and focuses on it so I can immediately start typing.
Update: You can also set your own key map: Tool Windows/Python Console. Hitting Esc will focus you back on the editor window.
The key is to hit the TAB key once (potentially twice) after you move into the Python Console (via whatever shortcut you specify in the keymap).
I think it also depends on whether the Python Console is docked - looks like it doesn't work if the Console is in another Window. So my current setup is having the Console docked:
You can use Alt + 4 or Alt + 5 where the digit is the window number. And then to refocus back to the edit you press Enter.
A couple of years later but i found my self in this situations, i believe the other answers are good enough for some but they lack some important information or at least i didn't found it.
You need to look for the term Python or debug console under tools if you want to focus to the console with the caret at it, add a keymap value for that (in my case i added ALT+2), do NOT use the python console under tool windows, for that it will focus on the python console but not the caret at it.
(done with pycharm 2020.1.1 in a ubuntu 20.04 lts machine)

How can I run the current file in PyCharm

How can I run the current file in PyCharm? I would like a single hotkey that will execute the current file (whether normal file, scratch file, or scratch buffer) using the project default python interpreter. I would like to NOT have to create a custom run configuration, but just launch with the default Python configuration. Is such a thing possible?
As it turns out, the action I was seeking is "Run context configuration" (or "Debug context configuration" for debugging). The default key binding on Windows is ctrl+shift+f10, or ctrl+option+R on Mac, as Ev. Kounis pointed out, although you can bind it to any key you like.
These settings can be found under the "Other" section in File->Settings->Keymap. The easiest way to find them is to simply use the search box.
Just right click on the tab of your file and click run "file name" or you can press CTRL+shift+F10
The key combination you are looking for is Ctrl + Shift + F10. This will run the current script with current being the one displayed in the viewer.
There are several alternatives:
Run context configuration from editor shortcut:
Mac: ⌃⇧R
Windows/Linux: Ctrl + Shift + F10
You can right click on the file, and then run Run 'filename'.
You can also run the shortcut to Find Action and then type run:
Mac: ⇧⌘A
Windows/Linux: Ctrl + Shift + A
If the current file was just run, you can simply use the Run shortcut:
Mac: ⌃R
Windows/Linux: Shift + F10
References:
PyCharm Shorcuts for Mac OS X
PyCharm Shorcuts for Windows and Linux
Alt+Shift+F10 and then select the script you want to run.
After that Shift+F10 will run the last script that has been run.
Keyboard shortcuts can be different on some machines. So you can just click right key on mouse and then "Run "(also you can select part of code and do the same)
File->Settings->Keymap->Run->Run and see your current keymap
Basically, if you just need to run the current .py file in PyCharm. Right-click inside the file, and you can click the "Run file.py" button, and it also tells you the shortcut which on Mac is Control + Shift + R.
To Run/Execute current python file in Pycharm use following keys in windows machine
Shift+Ctrl+F10
OR
for selected code (specific line that are selected/marked)
Shift+Alt+E
Running file with Ctrl+Shift+F10 or via Run menu has some disadvantages. For example, you cannot use the custom redirect input file.
I have created a project it is that will actually allow you to use currently opened py file when you press run / debug in a standard way. My project will remain actual at least until jetbrains fix non working macros in configurations. See bug report.
As of PyCharm 2022.2 there's a built-in "Current File" configuration.
When intalling on Pycharm select :
Add launchers dir to the PATH: Allows running this PyCharm instance from the Console without specifying the path to it.
:-)

Search in PyCharm interactive console command history

PyCharm keeps a command history for it's interactive Python console.
Is there a way to access this history with some sort of search instead of just browsing the entries with the arrow keys in the interactive console window?
My environment: PyCharm 2.7 EAP (124.138) on MacOS X 10.8.2.
As of PyCharm 3.1, while in the console, press ⌥⌘e, the "Browse History" window will come up, start typing to search for specific commands
Not available yet, please vote for the related feature requests:
PY-7922 In console, search history by typing prefix and pressing the "up" key
PY-5011 Ctrl+R in console should invoke history search like in bash
Nowadays, there is "Browse Console History" button located to the left of python console. It works on all OS where PyCharm works.
In Windows and Linux there is Ctrl+Alt+E which does exectly the same, but it may not work on Linux if it is overriden by system hotkey Alt.
In Windows you can use Ctrl Alt e

Is there a way in pycharm to close the run window and just look at the editor window using a keyboard shortcut

Because of vision problems, I have to keep the font in my Python programs in pycharm larger than the default setting. When I execute any program, the run window comes up at the bottom and every time I have to start working on the Python code in the editor window, I have to close the run window using a mouse.
Is there a way to close it using the keyboard shortcut? I could not find anything in the key map but there are so many settings that there is a chance that I may have missed it.
I also tried with using the distraction free option and it works very well. However, when I tried to find something within the code, it does not bring up the in-line window that allows me to type the keyword is searched for.
Please suggest if there is any way to close the run window or if there is any workaround so that I can return to working in a larger editor window.
Thank you for any inputs
shift+esc will hide the run window from within PyCharm.
If you want to access the run menu use: ctrl+shift+A
You can get a helpful cheatsheet of commands from within PyCharm by going to help -> Keymap Reference. This will provide the default key mapping for Windows and Linux
Have a look at Preferences -> Keymap under Tool Windows -> Run.
On Mac it is CMD+4.

Categories

Resources