1

As can be seen here:

https://www.jetbrains.com/pycharm/help/commenting-and-uncommenting-blocks-of-code.html

the shortcuts for commentting and uncommenting code in PyCharm are:

Ctrl+Slash 
Ctrl+Shift+Slash

How can I perform those shortcuts on Windows?

6
  • Both of those ARE Windows keyboard shortcuts within PyCharm. Why did you link to a IntelliJ IDEA article instead of a PyCharm article? – Ramhound Nov 20 '15 at 14:26
  • How do I execute the shortcut on a windows keyboard? "/" is the character I would potentially call slash. I have tried ctrl+/ and it does nothing. As I have to press shift+7 to get a slash, there is no difference for me in pressing the keys necissary for Ctrl+Slash or Ctrl+Shift+Slash. – user1283776 Nov 20 '15 at 14:54
  • @Ramhound: I have corrected the link – user1283776 Nov 20 '15 at 14:57
  • 1
    If you have to press "shift+7" to get a slash then you are not using a standard US keyboard. A standard 104 character US keyboard has a backward slash / on the ? and / key. Most IDEs allow you to configure the shortcut to comment code out, have you, tried changing it? You can do so here. Might be easier to just configure PyCharm to your keyboard layout though. Those shortcuts are (clearly) based on a standard 104-US keyboard – Ramhound Nov 20 '15 at 15:06
  • @Ramhound: Awesine, I did not think about it being possible to change. Thank you for your help! I've been going through the meny to comment and uncomment things for more than a month. Changing the keymap in settings fixed my problem. – user1283776 Nov 20 '15 at 15:30
1

It is possible to change the keyboard shortcuts in

Settings > Keymap

I searched for comment in the list of keyboard shortcuts and changed it to something more accssible to me (in my case CTRL+SHIFT+K).

0
0
  • Go to Settings > Keymap
  • Search for comment
  • Right-click Comment with Line Comment > Add Keyboard Shortcut
  • Hit the keyboard keys exactly as you would perform the shortcut. (do not try to write "Ctrl+...".
  • Apply and quit.
1
  • 1
    @downvoter, can you explain please ? – forzagreen Oct 11 '17 at 8:25
0

On a standard German keyboard for me "Strg + NumPad /" worked out ("NumPad /" is the key you would use for division if you calculate something).

0

Repeating your explanation from the comments in new words:

The US keyboard can reach the "/" button without using shift. From your question I read that you have a German/German-like keyboard where the "/" is in the index of the button "7". You need to press shift to reach "/". That is why you cannot make use of any shortcut that is differentiating between shift button / no shift button, since you need the shift button to reach the slash at all.

Now the answer to this could be a rather simple workaround:

I suggest changing your keyboard to US during programming. Then in case of a German keyboard, you can use Ctrl+"-" to comment out because you actually use the US Ctrl+"/" at that moment. And then Ctrl+Shift+"-" will comment in of course.

Use Windows key + space to switch the keyboard languages. The US keyboard must be added in the settings of course.

I type without looking at the keyboard anyway, thus it is no decrease in type efficiency, at the beginning, you might also consider buying an external US keyboard. After some time, you know both the local and the US keyboard by heart. I only change back to local languages when needed. By this, you can use all of the standard shortcuts, no reassignments needed.

3
  • What makes you believe the author isn't already using an US keyboard? You should consider improving this answer to directly address the author's question. – Ramhound Jul 27 '20 at 21:11
  • @Ramhound I thought this because of your comment "If you have to press "shift+7" to get a slash then you are not using a standard US keyboard." above. I have the same issue on a German keyboard, the user thus has kind of a German keyboard where the "/" is on the shifted 7 - and differentiating between shift and no-shift will not work as the user explains it: if you do not press shift, you will not reach the slash at all. The slash often cannot be pressed easily on non-US keyboards where it is on a shifted position. That is why I posted this, as I have used this "trick" since years. – questionto42 Jul 27 '20 at 21:28
  • Please improve your answer – Ramhound Jul 27 '20 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.