微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何将vim修复到包含Python注释行的正确缩进折叠?

我将 vim的折叠方法设置为缩进,这在编写 Python时非常好,除非我有一个注释行.例如,如果我有这个代码
def myFunction():
    # here is my comment
    myString = "hello"
    myInt = 2

如果我的光标在评论行上并输入“za”,我会得到一个错误,说“E490:找不到折叠”.如果我将光标放在“myString =”开头的行上,我将得到如下折叠:

def myFunction():
    # here is my comment
+--- 2 lines: myString = "hello" -------------------------

在这两种情况下,我想得到这个折叠:

def myFunction():
+--- 3 lines: # here is my comment -------------------------

基本上,评论行应该像其他任何事情一样对待.我没有提出在网络搜索的答案.有任何想法吗?谢谢!

你必须将foldignore设为无.
:set foldignore=

来自: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|.

原文地址:https://www.jb51.cc/vim/383560.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐