简体   繁体   English

使用 Jupyter 时如何在 Visual Studio Code 中复制单元格?

[英]How to copy cells in Visual Studio Code when using Jupyter?

I'm working with a Jupyter notebook.我正在使用 Jupyter 笔记本。 How would you copy cells in Visual Studio Code?您将如何在 Visual Studio Code 中复制单元格? C to copy and V to Paste did not work for me as it would online. C 复制和 V 粘贴对我来说不起作用,因为它会在线。

Also, Visual Studio doesn't seem to offer right click options when working in the notebook.此外,在笔记本中工作时,Visual Studio 似乎不提供右键单击选项。 Is there a extension that would give me some options such as Cut, Copy, Paste, Delete Cell, Etc.?是否有扩展程序可以为我提供一些选项,例如剪切、复制、粘贴、删除单元格等?

I'm a developer on this extension, and I have a bit of a two part answer for you.我是这个扩展的开发人员,我有一个两部分的答案给你。

  1. In the current (as of 2/16/21) stable release version of the extension notebook UI is done by a hosted webview, it was the only supported option at the time.在当前(截至 21 年 2 月 16 日)稳定版本的扩展笔记本 UI 由托管的 webview 完成,它是当时唯一受支持的选项。 As such it is lacking features both of Jupyter and of VS Code editor instances.因此,它缺乏 Jupyter 和 VS Code 编辑器实例的功能。 It does not currently support cutting, copying and pasting of cells.它目前不支持单元格的剪切、复制和粘贴。
  2. We are currently in the process of moving over to VS Code's new notebook UI that they provide.我们目前正在迁移到他们提供的 VS Code 的新笔记本 UI。 This allows better UI both for matching Jupyter and supporting more VS Code editor features.这为匹配 Jupyter 和支持更多 VS Code 编辑器功能提供了更好的 UI。 This current UI does allow for copying / cutting / pasting cells with the familiar Jupyter commands.当前的 UI 确实允许使用熟悉的 Jupyter 命令复制/剪切/粘贴单元格。

This support will not be added to the old editors, but currently the new UI is available if you use the extension with VS Code - Insiders and will soon start rolling out to VS Code Stable.此支持不会添加到旧编辑器中,但如果您将扩展与 VS Code - Insiders 一起使用,则当前新 UI 可用,并且很快将开始向 VS Code Stable 推出。

https://devblogs.microsoft.com/python/notebooks-are-getting-revamped/ https://devblogs.microsoft.com/python/notebooks-are-getting-revamped/

Short answer: Supported with VS Code - Insiders now, and will be supported on stable VS Code in the future.简短的回答:现在支持 VS Code - Insiders,将来会支持稳定的 VS Code。

The new version of the visual studio Jupyter Notebook extension support all the standard operations for one or multiple cells of the jupyter notebook.新版 Visual Studio Jupyter Notebook 扩展支持 jupyter notebook 的一个或多个单元格的所有标准操作。 For example, the following list shows some tested shutcuts:例如,以下列表显示了一些经过测试的快捷方式:

  • To copy a selected cell(s) use: ctrl+ccopy选定的单元格,请使用: ctrl+c
  • To paste a selected cell(s) use: ctrl+vpaste选定的单元格,请使用: ctrl+v
  • To cut a selected cell(s) use: ctrl+xcut选定的单元格,请使用: ctrl+x
  • To delete a selected cell(s) use: ctrl+xdelete选定的单元格,请使用: ctrl+x
  • etc.等等

Note that, as usual, to select multiples cells one should hold the ctrl button before selecting.请注意,像往常一样,对于 select 多个单元格,在选择之前应该按住ctrl按钮。

As of 2021-01-14, you can now select the cells, right click on any single one of the cells you selected (this will select them as a group if you select more than one) and have the option to press COPY . As of 2021-01-14, you can now select the cells, right click on any single one of the cells you selected (this will select them as a group if you select more than one) and have the option to press COPY . Or you can simply ctrl+C as a keyboard shortcut.或者您可以简单地按ctrl+C作为键盘快捷键。 The key here is when you copy and paste the cells to another notebook, your cursor needs to be outside any cells;这里的关键是当您将单元格复制并粘贴到另一个笔记本时,您的 cursor 需要在任何单元格之外; that is you need to press somewhere outside the cell before pasting.也就是说,您需要在粘贴之前按单元格外的某个位置。 In COLAB notebook, even if your cursor is on a cell, the copy and pasting method works.在 COLAB 笔记本中,即使您的 cursor 在单元格上,复制和粘贴方法也有效。 BUT here if you do that you will be pasting all of the codes inside the cell where your cursor is active;但是在这里,如果您这样做,您将在 cursor 处于活动状态的单元格中粘贴所有代码; it will not paste the actual cells you copied.它不会粘贴您复制的实际单元格。

Hope this wasn't too confusing.希望这不会太混乱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Visual Studio Code 的 Jupyter 单元中隐藏执行时间? - How to hide time of execution in Jupyter cells in Visual Studio Code? 在 Visual Studio Code 中使用 Jupyter 扩展时如何在单个单元格中查找和替换文本 - How to find and replace text in a single cell when using Jupyter extension inside Visual Studio Code 如何在 Visual Studio Code 中没有 Jupyter 单元格的情况下在 python (.py) 中生成 plot 图表? - How to plot graph in python (.py) without Jupyter cells in Visual Studio Code? 使用 jupyter R kernel 和 Visual Studio 代码 - Using jupyter R kernel with visual studio code jupyter 的 Visual Studio Code 快捷方式 - Visual Studio Code shortcuts for jupyter Visual Studio 代码 - 禁用 jupyter - Visual studio code - disable jupyter 当我使用 Visual Studio Code 运行 Jupyter notebook 时出现导入错误 - ImportError when I run Jupyter notebook with Visual Studio Code 使用 jupyter notebook 时,Visual Studio Code 不断崩溃 - Visual Studio Code crashes constantly when working with jupyter notebook 如何在执行代码时打开或关闭Visual Studio python(Jupyter)交互式窗口(2019)? - How do i turn on or off the Visual Studio python (Jupyter) interactive window (2019) when executing code? Visual Studio代码,如何复制文件名 - Visual studio code, how to copy the file name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM