python - 在 emacs 中将 python 代码提升一级?

标签 python emacs

有没有办法在 emacs 中为 python 代码提升一级缩进?

def foo():
  ...
  def bar(): # if I'm here, is there a way to go to def foo? 
    pass

最佳答案

使用 python-mode.el 分别调用 M-x py-up RETC-M-u

它会首先跳转到“def bar”的开头,然后向上进行第二次调用。

它的文档字符串说:

(向上py和可选缩进)

如果在内部,则向上或到表格开头。

如果在分隔形式 --string 或 list-- 内,则转到它的开头。

如果不在语句或 block 的开头,则转到它的开头。

如果位于语句或 block 的开头,则转到复合语句或定义所在位置的上一级开头。

关于python - 在 emacs 中将 python 代码提升一级?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19637475/

相关文章:

python - 使用Python的Mad Lib程序

python - 自动生成的 Python 构造函数

javascript - 仅在实际使用 cookie 时显示 cookie 通知

emacs - 如何修复终端 emacs 选择突出显示

emacs - 在 post-command-hook 中,kill-word 的 this-command 不知何故变成了 kill-region

Emacs 23 窗口.el

python 正则表达式匹配数字后跟字符串或什么都没有

python /iptables : Original Destination IP

python - 自动完成不起作用 : emacs elpy-mode

regex - 如何在 Emacs 的注释中不突出显示值?