Skip to content

Commit a3b3d91

Browse files
committed
Add folding for docstrings
1 parent 195d1ce commit a3b3d91

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

autoload/pymode/folding.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
let s:blank_regex = '^\s*$'
55
let s:def_regex = '^\s*\%(class\|def\) \w\+'
66
let s:decorator_regex = '^\s*@'
7+
let s:doc_begin_regex = '^\s*\%("""\|''''''\)'
8+
let s:doc_end_regex = '\%("""\|''''''\)\s*$'
9+
let s:doc_line_regex = '^\s*\("""\|''''''\).\+\1\s*$'
710

811

912
fun! pymode#folding#text() " {{{
@@ -41,6 +44,17 @@ fun! pymode#folding#expr(lnum) "{{{
4144
endif
4245
endif
4346

47+
if line =~ s:doc_begin_regex
48+
\ && line !~ s:doc_line_regex
49+
\ && prev_line =~ s:def_regex
50+
return ">".(indent / &shiftwidth + 1)
51+
endif
52+
53+
if line =~ s:doc_end_regex
54+
\ && line !~ s:doc_line_regex
55+
return "<".(indent / &shiftwidth + 1)
56+
endif
57+
4458
if line =~ s:blank_regex
4559
if prev_line =~ s:blank_regex
4660
return -1

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy