我将vim的foldmethod设置为缩进,在编写Python时非常有效,除非我有一个注释行.例如,如果我有这段代码:
def myFunction():
# here is my comment
myString = "hello"
myInt = 2
Run Code Online (Sandbox Code Playgroud)
如果我将光标放在注释行并键入"za",我会收到错误消息"E490:未找到折叠." 如果我将光标放在以"myString ="开头的行上,我会像这样折叠:
def myFunction():
# here is my comment
+--- 2 lines: myString = "hello" -------------------------
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,我想得到这个折叠:
def myFunction():
+--- 3 lines: # here is my comment -------------------------
Run Code Online (Sandbox Code Playgroud)
基本上评论行应该被视为其他任何东西.我没有想出网上搜索的答案.有任何想法吗?谢谢!