How can I block comment code in the IPython notebook?

前端 未结 3 1042
眼角桃花
眼角桃花 2021-01-30 21:51

I have defined a function in an IPython notebook and would like to be able to block comment a section of it. Intuitively, I\'d expect to be able to highlight a section of code,

3条回答
  •  醉话见心
    2021-01-30 22:07

    Solution that should work for any keyboard layout:

    Following this blogpost: https://towardsdatascience.com/jupyter-notebook-extensions-517fa69d2231, you can install some plugins for jupyter notebook with the command:

    pip install jupyter_contrib_nbextensions && jupyter contrib nbextension install 
    

    Now launch jupyter and go the new Nbextensions tab. There is a plugin called Comment/Uncomment Hotkey. Activate it and choose your hotkey. For example Alt + C. Now you can comment/uncomment a line or a block by selecting it and using your new hotkey.

提交回复
热议问题