我将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)
基本上评论行应该被视为其他任何东西.我没有想出网上搜索的答案.有任何想法吗?谢谢!
Sus*_*Pal 16
你必须将foldignore设置为空.
:set foldignore=
Run Code Online (Sandbox Code Playgroud)
来自:help foldignore:
'foldignore' 'fdi' string (default: "#")
Used only when 'foldmethod' is "indent". Lines starting with
characters in 'foldignore' will get their fold level from surrounding
lines. White space is skipped before checking for this character.
The default "#" works well for C programs. See |fold-indent|.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1622 次 |
| 最近记录: |