[英]PEP8, vim, and block of code
Sometimes, I am working on old Python code where PEP8 was not followed at all. 有时,我正在研究完全不遵循PEP8的旧Python代码。 I could run autopep8 on the whole code but that would generate a large diff.
我可以在整个代码上运行autopep8 ,但这会产生很大的差异。 What I want is to be able to select a block of Python code (via vim) and have just that block auto configured so that it obeys PEP8.
我想要的是能够选择一个Python代码块(通过vim)并自动配置该块,使其遵循PEP8。
With C++, you can use astyle with :20,40!astyle
to do just that. 使用C ++,您可以将astyle与
:20,40!astyle
一起使用。
Is there a vim equivalent? 是否有vim等效项?
Note that this is a clear example of not reading the man page for autopep8... 请注意,这是不阅读autopep8手册页的清晰示例。
OK, from reading autopep8's documentation, something like: 好的,通过阅读autopep8的文档,类似:
:20,40!autopep8 -i -
or (that was actually my first idea): 或者(实际上是我的第一个想法):
:20,40!autopep8 -
should work. 应该管用。
The general mechanism is called "filtering" and you can read all about it in :h filter
. 通用机制称为“过滤”,您可以在
:h filter
阅读有关它的全部信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.