我将vim的foldmethod设为了indent,在编写Python代码时非常有效,但是当我有一行注释时就出现了问题。比如,如果我的代码是这样的:
def myFunction():
# here is my comment
myString = "hello"
myInt = 2
如果我的光标在注释行上,然后我键入"za",就会收到错误消息"E490: No fold found." 如果我的光标在以 "myString =" 开头的行上,就会出现像这样的折叠:
def myFunction():
# here is my comment
+--- 2 lines: myString = "hello" -------------------------
在这两种情况下,我都希望能够得到这个折叠:
def myFunction():
+--- 3 lines: # here is my comment -------------------------
基本上,注释行应该像其他任何东西一样处理。我在网上搜索中没有找到答案。有什么想法吗?谢谢!