Created
August 3, 2016 20:28
-
-
Save TableBookspro/9799f0e5f9b7b1ffb318289733ec5ed5 to your computer and use it in GitHub Desktop.
Folding Expression for Fountain Files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! FountainFolds() | |
let thisline = getline(v:lnum) | |
let laterline = getline(v:lnum + 2) | |
if match(thisline, '^EXT') >= 0 | |
return ">1" | |
elseif match(thisline, '^INT') >= 0 | |
return ">1" | |
elseif match(thisline, '^Title:') >= 0 | |
return ">1" | |
elseif match(thisline, '^\.[^.]') >= 0 | |
return ">1" | |
elseif match(laterline, '^EXT') >= 0 | |
return "<1" | |
elseif match(laterline, '^INT') >= 0 | |
return "<1" | |
elseif match(laterline, '^Title:') >= 0 | |
return "<1" | |
elseif match(laterline, '^\.[^.]') >= 0 | |
return "<1" | |
else | |
return "=" | |
endif | |
endfunction | |
setlocal foldmethod=expr | |
setlocal foldexpr=FountainFolds() | |
function! FountainFoldText() | |
let foldsize = (v:foldend-v:foldstart) | |
return getline(v:foldstart).' ('.foldsize.' lines)' | |
endfunction | |
setlocal foldtext=FountainFoldText() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment