Skip to content

Instantly share code, notes, and snippets.

@BlueDrink9
Last active April 10, 2020 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlueDrink9/f40b3c816e5bcb349adcbc22eb753518 to your computer and use it in GitHub Desktop.
Save BlueDrink9/f40b3c816e5bcb349adcbc22eb753518 to your computer and use it in GitHub Desktop.
Fold percent-style cells (like used by jupytext) in vim
function GetJupytextFold(linenum)
if getline(a:linenum) =~ "^#\\s%%"
" start fold
return ">1"
elseif getline(a:linenum + 1) =~ "^#\\s%%"
return "<1"
else
return "-1"
endif
endfunction
setlocal foldexpr=GetJupytextFold(v:lnum)
setlocal foldmethod=expr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment