如何禁用Jupyter笔记本中从文本编辑器复制的隐藏字符?

huangapple go评论83阅读模式
英文:

I paste code in a jupyter notebook. The hidden characters from text editor are copied. How to disable this?

问题

我正在使用带有 Python 3 ipykernel 的 Jupyter Notebook。如果我从文本编辑器中粘贴代码到 Jupyter Notebook 中,文本编辑器中的所有隐藏字符都会显示为可见字符。
这很奇怪:例如,我可以按退格键删除隐藏字符中的空格,然后按空格键,它不会重新出现。

发生了什么情况,我该如何禁用它?

我尝试在此处粘贴字符,但它们会消失。这里有一张图片供参考:
如何禁用Jupyter笔记本中从文本编辑器复制的隐藏字符?

要解决这个问题,我使用 crtl+atabshift+tab,隐藏字符就会消失。我使用 Sublime 3 作为文本编辑器,但如果我在 gedit 中打开并粘贴与图像中显示的内容完全相同的内容到 Jupyter Notebook 中,我仍然看到隐藏字符。这个问题是新的(例如,一周前还没有发生)。

英文:

I am using Jupyter Notebook with the Python 3 ipykernel. If I paste code from a text editor into the Jupyter Notebook, all the hidden characters (in the text editor) show up as visible characters.
It is strange: e.g., I can backspace and erase the space hidden character, then hit space and it does not reappear.

What is happening and how do I disable it?

I tried to paste the character here, but they disappear. Here is an image for reference:
如何禁用Jupyter笔记本中从文本编辑器复制的隐藏字符?

To resolve this issue, I use crtl+a, tab, shift+tab, and the hidden characters disappear. I am use Sublime 3 as a text editor, but if I open gedit, and I type exactly what is displayed in the image and paste in Jupyter Notebooks, I still see the hidden characters. This issue is new (e.g., it wasn't occurring just a week ago).

答案1

得分: 3

我使用Sublime 3作为文本编辑器

你的问题归结为:“我的文本编辑器使用TAB字符而不是四个SPACE字符进行缩进”。

你可以通过运行tail my_source_code.py | hexdump -C验证这个诊断,
注意到0x09(十进制九)个TAB字符而不是0x20(十进制32)个SPACE字符。


访问编辑器的首选项屏幕,
并要求它使用SPACE而不是TAB。

英文:

> I am use Sublime 3 as a text editor

Your complaint boils down to "my text editor is indenting with TAB character rather than with four SPACE characters".

You can verify that diagnosis with tail my_source_code.py | hexdump -C
and notice the 0x09 (decimal nine) TAB characters instead
of 0x20 (decimal 32) SPACE characters.


Visit the Preferences screen in your editor
and ask it to use SPACE instead of TAB.

huangapple
  • 本文由 发表于 2023年2月18日 13:25:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75491391.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定