Skip to content

Instantly share code, notes, and snippets.

@TableBookspro
Created August 3, 2016 20:28
Show Gist options
  • Save TableBookspro/9799f0e5f9b7b1ffb318289733ec5ed5 to your computer and use it in GitHub Desktop.
Save TableBookspro/9799f0e5f9b7b1ffb318289733ec5ed5 to your computer and use it in GitHub Desktop.
Folding Expression for Fountain Files
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