英文:
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 中,文本编辑器中的所有隐藏字符都会显示为可见字符。
这很奇怪:例如,我可以按退格键删除隐藏字符中的空格,然后按空格键,它不会重新出现。
发生了什么情况,我该如何禁用它?
要解决这个问题,我使用 crtl+a
、tab
、shift+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:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论