[英]Why are the code colours different for every line in my Jupyter (Ubuntu)?
I was using Jupyter in Windows and just switched to Ubuntu. 我在Windows中使用Jupyter,刚刚切换到Ubuntu。 I found the colour of the code is very weird in the firefox browser.
我在firefox浏览器中发现代码的颜色很奇怪。 Eg it highlights the variables in every other line.
例如,它突出显示每个其他行中的变量。
I tried to solve this problem by installing a custom theme and the effect should be like 我试图通过安装自定义主题来解决这个问题,效果应该是这样的
Instead, it still highlights every other variable on my side, like 相反,它仍然突出了我身边的所有其他变量,比如
This just makes my eyes very tired when try to debug the code. 这只会让我的眼睛在尝试调试代码时非常疲惫。
I also tried disabling all the add-ons in Firefox which didn't help. 我也尝试禁用Firefox中的所有附加组件,但没有帮助。 Is there any setting that I can change to restore to the default colour display?
是否有任何设置可以更改为恢复默认颜色显示?
I sometimes get this if I'm copying/pasting from a source that has a different indentation size than that of the jupyter notebook. 如果我从具有与jupyter笔记本不同的缩进大小的源复制/粘贴,我有时会得到这个。 In your screenshot it looks like a small indent size so this seems like the likely culprit.
在你的截图中,它看起来像一个小的缩进大小,所以这似乎是可能的罪魁祸首。 Try highlighting the full block of indented code and hitting
ctrl+[
then ctrl+]
(this unindents the selected lines of code, then reindents them using the jupyter indent size). 尝试突出显示缩进代码的完整块并按下
ctrl+[
然后按ctrl+]
(这取消了所选的代码行,然后使用jupyter缩进大小重新使用它们)。
If this doesn't work, you might try checking to see if there are any custom indentation settings specified in either ".jupyter/nbconfig/notebook.json" or ".jupyter/custom/custom.js" (... or whatever the Windows equivalents are). 如果这不起作用,您可以尝试检查是否在“.jupyter / nbconfig / notebook.json”或“.jupyter / custom / custom.js”中指定了任何自定义缩进设置(...或者其他Windows等价物是)。
In ".jupyter/nbconfig/notebook.json", I have the indentUnit set to 4 spaces (and have also enabled linewrapping). 在“.jupyter / nbconfig / notebook.json”中,我将indentUnit设置为4个空格(并且还启用了行换行)。
{
"CodeCell": {
"cm_config": {
"indentUnit": 4,
"lineWrapping":true
}
}
}
Most editors allow you to set your indent size (Atom, sublime text, etc.) so you can avoid this issue in the future by making sure you have the same indent size everywhere you're swapping code to/from (assuming this is what's causing the red highlighting). 大多数编辑器允许您设置缩进大小(Atom,崇高文本等),以便您可以确保在将代码交换到/来自的任何地方都具有相同的缩进大小,以避免此问题(假设这是什么的)导致红色突出显示)。 Python's default is 4 so def recommend sticking with that.
Python的默认值是4所以def建议坚持使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.