I want to comment out a block of multiple lines in Jupyter (Ipython Notebook), but can't find out how to do that in this current version.
It used to be in one of the drop down menus but is no longer there.
How do you comment out multi-line blocks of code at once?
This is not a duplicate because the solution given in the following link doesn't seem to work anymore:
How can I block comment code in the IPython notebook?
Ctrl + / does nothing.
After searching for a while I have found a solution to comment on an AZERTY mac. The shortcut is
Ctrl +/= key
On MacOS 10.11 with Firefox and a German keyboard layout it is Ctrl + ?
Ctrl + / works for me in Chrome browser in MS Windows
I have not yet managed to find the best way possible. Since I am using a keyboard with
Finnish
layout, some of the answers do not work for me (e.g. user5036413's answer).However, in the meantime, I have come up with a solution that at least helps me not to comment each and every line one by one. I am using
Chrome browser
inMS Windows
and I have not checked other possibilities though.The solution:
It uses the fact that you can have multiple line cursors in an
Ipython Notebook
.Press the Alt button and keep holding it. The cursor should change its shape into a big plus sign. The next step is, using your mouse, to point to the beginning of the first line you want to comment and while holding the Alt button pull down your mouse until the last line you want to comment. Finally, you can release the Alt button and then use the
#
character to comment. Voila! You have now commented multiple lines.I tried this on Mac OSX with Chrome 42.0.2311.90 (64-bit) and this works by using CMD + /
Could it be a browser related problem? Did you try Firefox or IE?
If you have a Mac and not a English keyboard: Cmd-/ is still easy to produce.
Follow the below steps:
Whenever you want a Cmd-/, you have to change to the ABC keyboard (in your menu row at the top of your screen,if you have ticked it to be shown there in the
System Settings - Keyboard tab
).Cmd and the key to the left of the right "
shift key
" gives you Cmd-/.P.S: Don't forget to switch back to your normal keyboard.