簡體   English   中英

VS Code editing.ipynb 文件:如何折疊筆記本單元格?

[英]VS Code editing .ipynb file: How to collapse notebook cells?

我正在使用 Jupyter Notebook 擴展在 VS Code 中編輯 an.ipynb 文件。 我似乎無法弄清楚如何折疊(或展開)單元格。

有人可以向我解釋如何做到這一點(使用熱鍵或不使用熱鍵),或者就我可能做錯的事情給出想法嗎?

我在三組條件下嘗試了下面顯示的每個熱鍵:1. 選中單元格輸入左側的藍色豎條,2. 單元格左側的藍色豎條選擇 output,3. 在我的單元格輸入中使用我的 cursor。

“筆記本:折疊單元格輸入”和“筆記本:折疊單元格輸出”,具有默認綁定

目前,VS Code 的 Jupyter 不支持使用這個 function,您可以參考這個鏈接: Jupyter notebook cell code fold 和 output 視圖擴展請求

另外,請嘗試使用“ Visual Studio Code Insiders ”,在 Jupyter 的單元格中單擊鼠標右鍵,然后 select“ Collapse Cell Input ”或“ Collapse Cell Output ”:

前:

在此處輸入圖像描述

后:

在此處輸入圖像描述

在我的 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' 的詳細帖子在這里

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

只需右鍵單擊代碼單元格和 select '折疊單元格輸出'。

或者,單擊代碼單元(確保您處於命令模式)並使用鍵盤快捷鍵 ⌘KT(在 Mac 上)或在 Windows 上使用 Ctrl-K T。

折疊單元格輸出

另一種折疊單元格的方法即將發布到 v1.64。

單元格折疊 UI

筆記本單元格的左側有一個藍色條,表示它們已聚焦。 此欄現在是交互式的 - 您可以單擊頂部折疊單元格輸入,單擊底部折疊 output。

細胞崩潰演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM