As can be seen here:


the shortcuts for commentting and uncommenting code in PyCharm are:


How can I perform those shortcuts on Windows?

  • 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, 2015 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. Nov 20, 2015 at 14:54
  • @Ramhound: I have corrected the link Nov 20, 2015 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, 2015 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. Nov 20, 2015 at 15:30

4 Answers 4


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).

  • 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
    @downvoter, can you explain please ?
    – forzagreen
    Oct 11, 2017 at 8:25

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


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.

  • 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, 2020 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. Jul 27, 2020 at 21:28
  • Please improve your answer
    – Ramhound
    Jul 27, 2020 at 22:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .