如何将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|.

相关文章

解决方案:解决linux下vim乱码的情况:(修改vimrc的内容)全...
Linuxvi/vim所有的UnixLike系统都会内建vi文书编辑器,其他的...
      vim正则匹配:空行:/^$/  /^[\t]*$/注释...
$select-editorSelectaneditor.Tochangelater,run'sele...
上次手贱忘了保存,这次就简单做个备忘吧,把踩过的坑记一下...
Linux之文本编译器小结vim的优势所有的UNIX-LIKE习通都会内置...