I set vim’s foldmethod to indent which works very well when writing Python except when I have a comment line. For example, if I have this bit of code:
def myFunction():
# here is my comment
myString = "hello"
myInt = 2
If I have my cursor on the comment line and type “za” I get get an error saying “E490: No fold found.” If I have the cursor on the line beginning with “myString = ” I will geta fold like this:
def myFunction():
# here is my comment
+--- 2 lines: myString = "hello" -------------------------
In both cases I would like to get this fold:
def myFunction():
+--- 3 lines: # here is my comment -------------------------
Basically the comment line should be treated like anything else. I haven’t come up with an answer from searching the web. Any ideas? Thanks!
You have to set foldignore to nothing.
From
:help foldignore: