emacs - Emacs 和 python 模式自动缩进
问题描述
python 模式自动缩进似乎基于样式做出了很多假设。在某些情况下,如何配置缩进方式,或者使其像 vim 一样缩进。
例如,如果我有以下功能:
def some_function(
arg1,
arg2,
):
pass
如果我走到arg2
行尾,按回车键,然后输入arg3,
,这就是我将得到的:
def some_function(
arg1,
arg2,
arg3,
):
pass
我想要的是:
def some_function(
arg1,
arg2,
arg3,
):
pass
我怎样才能让它在这里做我想做的事?
我已经尝试过(setq indent-line-function 'indent-relative)
,哪种是我想要的,除非我按两次回车,光标将位于行的开头(似乎它只检查最后一行以确定相对性)。
在 vim 中,我可以输入def some_function(
并按 enter,它会自动缩进 4 个空格。如果我输入两次 enter ,它仍然会缩进 4 个空格。这是我最想要的。
提前致谢!
解决方案
看起来这解决了我遇到的自动缩进问题。这不是让 emacs 使用 vim 样式缩进的方法。如果我弄清楚了,我会把它添加到这个答案中。
(add-hook 'python-mode-hook
(lambda ()
(setq python-indent-def-block-scale 1)))
推荐阅读
- flutter - 如何在现代 shap 设备中修复 appbar 中心小部件
- javascript - 如何选择类中的所有元素,包括动态创建的元素?
- image - 未找到 gh-pages 相对路径
- javascript - 如何使用三元运算符使用react返回jsx?
- reactjs - reactJS useState - 如何在多个代码块中设置变量
- python - 在 Python 中使用 Tkinter 的 .grid() 函数时,sticky="W" 未将文本与窗口左侧对齐
- node.js - 卷挂载在 docker-compose 中的工作原理
- javascript - 删除 y 轴边距
- html - 如何在 CSS 中没有任何内容的情况下设置 height=100%?
- spring-security - JHipster 微服务和网关 - 网关可扩展性