Mehdi
Mehdi

Reputation: 1525

Comment code in Pycharm with a German keyboard

Does anybody using a German keyboard have found a solution to this? Ctrl+/ is not possible since it is necessary to push shift+7 to get the slash. But when I do Ctrl+shift+7 I get a bookmark called 7 on that line. Commenting code is very time wasting like that, especially when commenting xml lines.

Upvotes: 43

Views: 30533

Answers (7)

klingeron
klingeron

Reputation: 1

If you don't want to redo the keymaps yourself, there's a plug-in which has predefined remaps for some languages (- instead of / for german, ...): https://plugins.jetbrains.com/plugin/14625-keymap-nationalizer

You can also customize the remaps

Upvotes: 0

Žorž Appolo
Žorž Appolo

Reputation: 11

Settings -> Keymap -> Main Menu -> Code -> Comment Actions

(or put 'comment' in search box)

You will see 'Comment with line Comment', remove what is there (right click, remove), add what you want after.

As a beginner, I need only 1 or 2 shortcuts, and one of them is comments, so just delete whatever is your shortcut already assigned to when the window pops up.

Upvotes: 1

Kojuru
Kojuru

Reputation: 51

I solved it by mapping the US keyboard layout (QWERTY) to the fn-key (I don't have numberpad): enter image description here

enter image description here

By pressing first [fn] and then [CMD] + [-] it will comment out the marked code lines in pycharm. I hope this might help others who don't have a numberpad.

Upvotes: 0

mrk
mrk

Reputation: 10386

Keyboard shortcuts are completely customizable in PyCharm

Following is an instruction given in PyCharm2017.1 Help:

  1. Open the Settings dialog box, and click Keymap.

  2. Select one of the pre-configured Keymaps, which you want to use as the base for the new one, and click Copy. Accept the default name, or change it as required.

  3. In the content pane of actions, select the desired action.

  4. Configure keyboard shortcuts. To do that, follow these steps:

  5. Click /help/img/idea/2017.1/properties.gif on the toolbar, or right-click the selected action, and choose Add Keyboard Shortcut. Enter Keyboard Shortcut dialog box opens.

  6. Press the keys to be used as shortcuts. The keystrokes are immediately reflected in the First Stroke field. Optionally, select the check box next to Second Stroke and press keys to be used as alternative keyboard shortcuts. As you press the keys, the Preview field displays the suggested combination of keystrokes, and the Conflicts field displays warnings, if some of the keystrokes are already assigned to the other actions.

Note: Click OK with the mouse pointer to create a shortcut and bind it with an action.

Upvotes: 5

wedi
wedi

Reputation: 1422

I assigned CMD + # to line comments on my German notebook keyboard without numpad. I think this is a good mnemonic for python comments although editors use something with / in their comment shortcuts (C is a bit older than Python :).

Mac: CMD + , -> Keymap -> search for 'comment' -> right click -> Add Keyboard Shortcut -> pressCMD + #. (As already outline by LazyOne)

Unfortunately I did not get CMD + SHIFT + # to work for block comments. There seems to be a SHIFT problem with pycharms keyboard map.

Upvotes: 3

Andreas Wilkes
Andreas Wilkes

Reputation: 1041

If you have a numberpad on your keyboard you can use Ctrl and the division sign on your numpad.

Found this in the Bugreports pointed out by LazyOne

Upvotes: 51

LazyOne
LazyOne

Reputation: 165228

Choose another working-for-you shortcut for that action at Settings (Preferences on Mac) | Keymap (just use search field to find the right action).

Other than that: watch these tickets (star/vote/comment) to get notified on progress.

Upvotes: 20

Related Questions