我用Vim编程Python有一段时间了,但有一件事我还没弄明白怎么做,把它设置为自动缩进到上一个openparen的级别。在
根据pep8,如果你有一个开放的paren,你需要把这条线分成80列,那么你应该在这个开放的paren上继续下一行。示例:
calling_some_really_long_function(that, has, way, too, many, arguments, to, fit,
on, one, line)
显然,这是一个疯狂的例子,但这正是您在python中应该如何中断行的。在
我真正想做的是设置Vim,这样当我输入fit,<cr>
时,它会将我的光标放在打开paren右边的下一行,这样我就可以只键入on,
等,而不是事先组合使用<tab>
和{
我不认为我会信任Vim中python代码的自动格式化程序,但是如果它也能工作的话,那就有好处了。在
使用}
gq
,可以使用可视块覆盖整个选择,也可以使用移动,如gqq
或{这可以改进一点,但99%的时间都可以。在.vimrc中添加以下内容:
它至少从V7.0开始就包含在Vim中:
请参阅以下来自
usr/share/vim/vim80/indent/python.vim
(第74行)https://github.com/vim/vim/blob/master/runtime/indent/python.vim的片段相关问题 更多 >
编程相关推荐