加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-16 01:37:42 所属栏目:安全 来源:网络整理
导读:我将 vim的折叠方法设置为缩进,这在编写 Python时非常好,除非我有一个注释行.例如,如果我有这个代码: def myFunction(): # here is my comment myString = "hello" myInt = 2 如果我的光标在评论行上并输入“za”,我会得到一个错误,说“E490:找不到折叠”.
我将 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|.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读