【问题标题】:VS Code editing .ipynb file: How to collapse notebook cells?VS Code 编辑 .ipynb 文件:如何折叠笔记本单元格?
【发布时间】:2021-06-26 18:43:33
【问题描述】:

我正在使用 Jupyter Notebook 扩展在 VS Code 中编辑 .ipynb 文件。我似乎不知道如何折叠(或展开)单元格。

有人可以向我解释如何做到这一点(使用热键或不使用热键),或者就我可能做错的地方给出想法吗?

我在三组条件下尝试了下面显示的每个热键:1. 选中单元格输入左侧的蓝色竖线,2. 左侧的蓝色竖线选择我的单元格输出,3. 将光标放在单元格输入中。

【问题讨论】:

    标签: python visual-studio-code jupyter editor


    【解决方案1】:

    目前,VS Code 的 Jupyter 不支持使用该功能,可参考此链接:Jupyter notebook cell code folding and output view expanding request

    另外,请尝试使用“Visual Studio Code Insiders”,在 Jupyter 的单元格中单击鼠标右键,选择“Collapse Cell Input”或“Collapse Cell Output”:

    之前:

    之后:

    【讨论】:

      【解决方案2】:

      在我的 VSCode 内部人员构建版本 1.61.0 中,它可以工作。

      什么工作->

       a) One shot expand/collapse all cells(code/output) in '.ipynb'(notebook)
       b) Single cell code/output expand/collapse in '.ipynb'(notebook)
       c) code folding in `.py` file with `#%%` (hierarchy style)
      
      1. .ipynb(您的要求)

        有可用的键绑定:jupyter.notebookeditor.expandallcells/collapseallcells

        它有什么作用?

                Expands/collapses all cells in one shot
        

        找到这个设置->

             Top menu File->Preferences->Keyboard Shortcuts
             In search("Type to search in keybindings"...top side) 
             type "Notebook Expand" or "Notebook Collapse", check out:
        
                     Notebook: Expand/Collapse All Cells, 
                     Notebook: Expand/Collapse Cell Input and 
                     Notebook: Expand/Collapse Cell Output
        
        
             Its possible to expand/collapse single/all cells with these shortcuts keys.
        

      为了完成这个答案(其他人已经回答)->

          1.  double click gutter area (immediate space on left side of code cell) to Expand/Collapse cell (code/output)
      
          2.  right click on gutter area to get Expand/Collapse cell (code/output)
      
      1. “.ipynb”和“.py”的详细帖子here

      【讨论】:

      • 请在您的回答中提供更多详细信息。正如目前所写的那样,很难理解您的解决方案。
      【解决方案3】:

      我使用的是 1.58.2 版本,现在可以使用此功能!

      只需右键单击代码单元格并选择“折叠单元格输出”。

      或者,单击代码单元格(确保您处于命令模式)并使用键盘快捷键 ⌘K T(在 Mac 上)或 Ctrl-K T 在 Windows 上。

      【讨论】:

        猜你喜欢
        • 2021-08-28
        • 2016-01-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-08-07
        • 2014-01-28
        • 1970-01-01
        相关资源
        最近更新 更多