如何在Jupyter中插入文字标签而不是自动完成? [英] How to insert a literal tab instead of auto-completing in Jupyter?

查看:250
本文介绍了如何在Jupyter中插入文字标签而不是自动完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很容易缩进整行.

  1. 只需突出显示整行,然后按 Tab

转到行的开头,然后按 Tab

Go to the start of the line and press Tab

单击行中的任意位置,然后按 Ctrl + ]

Click anywhere in the line and press Ctrl + ]

现在,问题是如何在行的中间插入缩进.

Now the problem is how to insert indent in the middle of the line.

还有,如何在行尾缩进.

And also, how to indent at the end of the line.

使用场景示例:

# Hyperparameters
LENGTH = 10 # length of foo
TEMP = 20 # temperature of bar
IV = 99.99 # induction variability of foo bar

我们确实要:

# Hyperparameters
LENGTH = 10    # length of foo
TEMP = 20      # temperature of bar
IV = 99.99     # induction variability of foo bar

甚至更好(在某些情况下):

Or even better (in some cases):

# Hyperparameters
LENGTH = 10        # length of foo
TEMP   = 20        # temperature of bar
IV     = 99.99     # induction variability of foo bar

  1. 请注意,但是通过按下 Tab 按钮,我们实际上是在调用自动​​完成而不是缩进.
  2. 当然,我们总是可以使用空格键来手动对齐它们,但是每次我们调整超参数时都必须这样做.
  1. Note that by pressing the Tab button however, we are actually calling auto-complete instead of indenting.
  2. Of course we can always manual align them by using spacebar, but then we will have to do this every time we tune the hyperparameters.

那么,如何在Jupyter中缩进而不是自动完成?

So, how to indent instead of auto-completing in Jupyter?

P.S.是的,我知道print("\ t"),可以复制输出并粘贴缩进.但这是不可取的.

P.S. Yes, I am aware of print("\t"), copying the output and pasting the indent. But that is not desirable.

推荐答案

一种替代方法是使用Alt键盘顺序.
在这种情况下,它将为Alt + 09.它大约是人们希望的那么短.

One alternative would be to use the Alt keyboard sequence.
In this case it would be Alt + 09. It is about as short as one could hope for.

要实现此目的,您需要在键盘上使用小键盘,因为键盘上的第一行数字无法产生Alt键盘序列.

For this to work you need a numpad on your keyboard, as the top row of numbers on the keyboard does not work to produce Alt keyboard sequences.

但是,这确实在标签上留下了难看的箭头,这似乎是Jupyter Notebooks显示标签字符的方式.

However, this does leave rather ugly arrows in place of the tab, which seems to be the way Jupyter Notebooks displays tab characters.

这篇关于如何在Jupyter中插入文字标签而不是自动完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆