changeset 34935:e8ddbfaf0c85

runtime(vim): Update base-syntax, fix nested function folding (#14397) Commit: https://github.com/vim/vim/commit/4ba70cab37d2a625d8c59bb136070ef9d1976934 Author: dkearns <dougkearns@gmail.com> Date: Mon Apr 15 04:32:56 2024 +1000 runtime(vim): Update base-syntax, fix nested function folding (https://github.com/vim/vim/issues/14397) Only match function folding start and end patterns at the start of a line, excluding heredocs and :append/:change/:insert commands. Fixes #14393 Signed-off-by: Christian Brabandt <cb@256bit.org> Signed-off-by: Doug Kearns <dougkearns@gmail.com>
author Christian Brabandt <cb@256bit.org>
date Sun, 14 Apr 2024 20:45:05 +0200
parents 9e7a0095db66
children f734fd771c45
files runtime/syntax/generator/vim.vim.base runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump runtime/syntax/testdir/dumps/vim_ex_def_fold_03.dump runtime/syntax/testdir/dumps/vim_ex_def_fold_04.dump runtime/syntax/testdir/dumps/vim_ex_def_fold_05.dump runtime/syntax/testdir/dumps/vim_ex_def_fold_06.dump runtime/syntax/testdir/dumps/vim_ex_def_fold_07.dump runtime/syntax/testdir/dumps/vim_ex_def_fold_99.dump runtime/syntax/testdir/dumps/vim_ex_def_nested_00.dump runtime/syntax/testdir/dumps/vim_ex_def_nested_99.dump runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_00.dump runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_01.dump runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_99.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_01.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_02.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_03.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_04.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_05.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_06.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_07.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_08.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_09.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_10.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_11.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_12.dump runtime/syntax/testdir/dumps/vim_ex_function_fold_99.dump runtime/syntax/testdir/dumps/vim_ex_function_nested_00.dump runtime/syntax/testdir/dumps/vim_ex_function_nested_01.dump runtime/syntax/testdir/dumps/vim_ex_function_nested_99.dump runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_00.dump runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_01.dump runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_02.dump runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_99.dump runtime/syntax/testdir/input/vim_ex_def_fold.vim runtime/syntax/testdir/input/vim_ex_def_nested.vim runtime/syntax/testdir/input/vim_ex_def_nested_fold.vim runtime/syntax/testdir/input/vim_ex_function_fold.vim runtime/syntax/testdir/input/vim_ex_function_nested.vim runtime/syntax/testdir/input/vim_ex_function_nested_fold.vim runtime/syntax/vim.vim
diffstat 41 files changed, 582 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/syntax/generator/vim.vim.base
+++ b/runtime/syntax/generator/vim.vim.base
@@ -3,7 +3,7 @@
 " Maintainer:	   Hirohito Higashi <h.east.727 ATMARK gmail.com>
 "	   Doug Kearns <dougkearns@gmail.com>
 " URL:	   https://github.com/vim-jp/syntax-vim-ex
-" Last Change:	   2024 Apr 12
+" Last Change:	   2024 Apr 13
 " Former Maintainer: Charles E. Campbell
 
 " DO NOT CHANGE DIRECTLY.
@@ -191,9 +191,9 @@ syn cluster vimExprList contains=vimEnvv
 "   (buftype != nofile test avoids having append, change, insert show up in the command window)
 " =======================
 if &buftype != 'nofile'
- syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$"		matchgroup=vimCommand end="^\.$""
- syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$"		matchgroup=vimCommand end="^\.$""
- syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$"		matchgroup=vimCommand end="^\.$""
+ syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$"		matchgroup=vimCommand end="^\.$" extend
+ syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$"		matchgroup=vimCommand end="^\.$" extend
+ syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$"		matchgroup=vimCommand end="^\.$" extend
 endif
 
 " Behave! {{{2
@@ -244,12 +244,14 @@ if !exists("g:vimsyn_noerror") && !exist
  syn match	vimOperError	")"
 endif
 
-" Functions : Tag is provided for those who wish to highlight tagged functions {{{2
+" Functions: Tag is provided for those who wish to highlight tagged functions {{{2
 " =========
 syn cluster	vimFuncList	contains=vimFuncBang,vimFunctionError,vimFuncKey,vimFuncSID,Tag
 syn cluster	vimDefList	contains=vimFuncBang,vimFunctionError,vimDefKey,vimFuncSID,Tag
-syn cluster	vimFuncBodyList	contains=@vimCmdList,vimCmplxRepeat,vimComment,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimFuncVar,vimLetHereDoc,vimLineComment,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst
-syn cluster	vimDefBodyList	contains=@vimCmdList,vimCmplxRepeat,vim9Comment,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vim9LineComment,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst
+
+syn cluster	vimFuncBodyCommon	contains=@vimCmdList,vimCmplxRepeat,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst,vimFuncFold
+syn cluster	vimFuncBodyList	contains=@vimFuncBodyCommon,vimComment,vimLineComment,vimFuncVar,vimInsert
+syn cluster	vimDefBodyList	contains=@vimFuncBodyCommon,vim9Comment,vim9LineComment
 
 syn region	vimFuncPattern	contained		matchgroup=vimOper start="/" end="$" contains=@vimSubstList
 syn match	vimFunction	"\<fu\%[nction]\>"	skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimFuncKey
@@ -284,9 +286,9 @@ syn match	vimEndfunction	"\<endf\%[uncti
 syn match	vimEnddef	"\<enddef\>"
 
 if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
- syn region	vimFuncFold	start="\<fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*("	end="\<endf\%[unction]\>" contains=vimFunction fold keepend transparent
- syn region	vimFuncFold	start="\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\)\+("		end="\<enddef\>"	        contains=vimDef      fold keepend transparent
- syn region	vimFuncFold	start="\<def\s\+new\i\+("				end="\<enddef\>"	        contains=vimDef      fold keepend transparent
+ syn region	vimFuncFold	start="^\s*:\=\s*fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*("	end="^\s*:\=\s*endf\%[unction]\>" contains=vimFunction fold keepend extend transparent
+ syn region	vimFuncFold	start="^\s*:\=\s*def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\)\+("		end="^\s*:\=\s*enddef\>"          contains=vimDef      fold keepend extend transparent
+ syn region	vimFuncFold	start="^\s*:\=\s*def\s\+new\i\+("					end="^\s*:\=\s*enddef\>"          contains=vimDef      fold keepend extend transparent
 endif
 
 syn match	vimFuncVar   contained	"a:\%(\K\k*\|\d\+\)\>"
@@ -502,7 +504,7 @@ syn keyword	vimUnlet	unl[et]		skipwhite 
 syn match	vimUnletBang	contained	"!"	skipwhite nextgroup=vimUnletVars
 syn region	vimUnletVars	contained	start="$\I\|\h" skip="\n\s*\\" end="$" end="|" contains=vimVar,vimEnvvar,vimContinue,vimString,vimNumber
 
-VimFoldh syn region vimLetHereDoc	matchgroup=vimLetHereDocStart start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\s*\z1\s*$'
+VimFoldh syn region vimLetHereDoc	matchgroup=vimLetHereDocStart start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\s*\z1\s*$' extend
 syn keyword	vimLet	var		skipwhite nextgroup=vimVar,vimFuncVar,vimLetHereDoc
 
 " For: {{{2
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_01.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f|!| |F|o@1|(|)|:| |n|u|m|b|e|r|-@42
 | +0#0000000#ffffff0@74
-@57|1|9|,|1| @9|1|6|%| 
+@57|1|9|,|1| @9|1|2|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_02.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |"+0#0000e05&| |s|a|m|e| |n|a|m|e| |a|s| |a|n| |E|x| |c|o|m@1|a|n|d| +0#0000000&@46
 |++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |s|:|l|s|(|)|-@50
-| +0#0000000#ffffff0@56|3|7|,|1| @9|3|4|%| 
+| +0#0000000#ffffff0@56|3|7|,|1| @9|2|7|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_03.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_03.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|:| |l|i|s|t|<|d|i|c|t|<|n|u|m|b|e|r|>@1|-@31
 | +0#0000000#ffffff0@74
-@57|5@1|,|1| @9|5@1|%| 
+@57|5@1|,|1| @9|4@1|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_04.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_04.dump
@@ -17,4 +17,4 @@
 |++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
 | +0#0000000#ffffff0@74
 @75
-@57|7|3|,|1| @9|7@1|%| 
+@57|7|3|,|1| @9|6|2|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_05.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_05.dump
@@ -15,6 +15,6 @@
 @75
 |++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
 | +0#0000000#ffffff0@74
-|~+0#4040ff13&| @73
-|~| @73
-| +0#0000000&@56|9|1|,|0|-|1| @7|B|o|t| 
+@75
+|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
+@57|9|1|,|0|-|1| @7|8|2|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_06.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_06.dump
@@ -1,20 +1,20 @@
-| +0&#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
-| +0#0000000#ffffff0@74
-@75
-|"+0#0000e05&| |p|a|r|a|m|e|t|e|r|s| +0#0000000&@62
-> @74
-|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|x|:| |b|o@1|l|,| |y| |=| |4|2|,| |z|:| |s|t|r|i|n|g| |=| |"|z|e|d|"|)|-@17
-| +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|-@52
 | +0#0000000#ffffff0@74
 @75
 |"+0#0000e05&| |c|o|m@1|e|n|t|s| +0#0000000&@64
 @75
-|++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+>++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+@75
+|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
+@75
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|d|e|f| |F|o@1|(|)|-@50
 | +0#0000000#ffffff0@74
 |~+0#4040ff13&| @73
-|~| @73
-|~| @73
-|~| @73
-| +0#0000000&@56|1|0|9|,|0|-|1| @6|B|o|t| 
+| +0#0000000&@56|1|0|9|,|1| @8|B|o|t| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_07.dump
@@ -0,0 +1,20 @@
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+> +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|d|e|f| |F|o@1|(|)|-@50
+| +0#0000000#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|2|7|,|0|-|1| @6|B|o|t| 
--- a/runtime/syntax/testdir/dumps/vim_ex_def_fold_99.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_fold_99.dump
@@ -1,20 +1,20 @@
 | +0&#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
-| +0#0000000#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
-| +0#0000000#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
-| +0#0000000#ffffff0@74
-@75
-|"+0#0000e05&| |p|a|r|a|m|e|t|e|r|s| +0#0000000&@62
-@75
-|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|x|:| |b|o@1|l|,| |y| |=| |4|2|,| |z|:| |s|t|r|i|n|g| |=| |"|z|e|d|"|)|-@17
-| +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|-@52
 | +0#0000000#ffffff0@74
 @75
 |"+0#0000e05&| |c|o|m@1|e|n|t|s| +0#0000000&@64
 @75
 |++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+@75
+|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
+@75
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |d|e|f| |F|o@1|(|)|-@51
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|d|e|f| |F|o@1|(|)|-@50
 > +0#0000000#ffffff0@74
-@57|1@1|0|,|0|-|1| @6|B|o|t| 
+@57|1|3|0|,|0|-|1| @6|B|o|t| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_nested_00.dump
@@ -0,0 +1,20 @@
+>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@64
+|#+0#0000e05&| |V|i|m|9| |:|d|e|f| |c|o|m@1|a|n|d| |(|n|e|s|t|e|d|)| +0#0000000&@46
+@75
+|c+0#af5f00255&|l|a|s@1| +0#0000000&|T|e|s|t| @64
+@4|c+0#af5f00255&|o|n|s|t| +0#0000000&|n+0#00e0e07&|a|m|e|:+0#0000000&| |s|t|r|i|n|g| @52
+@75
+@4|d+0#af5f00255&|e|f| +0#0000000&|n|e|w|(+0#e000e06&|)| +0#0000000&@61
+@8|d+0#af5f00255&|e|f| +0#0000000&|N|a|m|e|(+0#e000e06&|)|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@48
+@12|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|G|i|v|e|N|a|m|e|(+0#e000e06&|)| +0#0000000&@43
+@16|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|a|n|y|"| +0#0000000&@46
+@12|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@51
+@75
+@12|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|G|i|v|e|N|a|m|e|(+0#e000e06&|)| +0#0000000&@45
+@8|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@60
+@75
+@8|t+0#af5f00255&|h|i|s|.|n+0#0000000&|a|m|e| |=+0#af5f00255&| +0#0000000&|N|a|m|e|(+0#e000e06&|)| +0#0000000&@48
+@4|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@64
+|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
+@75
+@57|1|,|1| @10|T|o|p| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_nested_99.dump
@@ -0,0 +1,20 @@
+|#+0#0000e05#ffffff0| |V|i|m|9| |:|d|e|f| |c|o|m@1|a|n|d| |(|n|e|s|t|e|d|)| +0#0000000&@46
+@75
+|c+0#af5f00255&|l|a|s@1| +0#0000000&|T|e|s|t| @64
+@4|c+0#af5f00255&|o|n|s|t| +0#0000000&|n+0#00e0e07&|a|m|e|:+0#0000000&| |s|t|r|i|n|g| @52
+@75
+@4|d+0#af5f00255&|e|f| +0#0000000&|n|e|w|(+0#e000e06&|)| +0#0000000&@61
+@8|d+0#af5f00255&|e|f| +0#0000000&|N|a|m|e|(+0#e000e06&|)|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@48
+@12|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|G|i|v|e|N|a|m|e|(+0#e000e06&|)| +0#0000000&@43
+@16|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|a|n|y|"| +0#0000000&@46
+@12|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@51
+@75
+@12|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|G|i|v|e|N|a|m|e|(+0#e000e06&|)| +0#0000000&@45
+@8|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@60
+@75
+@8|t+0#af5f00255&|h|i|s|.|n+0#0000000&|a|m|e| |=+0#af5f00255&| +0#0000000&|N|a|m|e|(+0#e000e06&|)| +0#0000000&@48
+@4|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@64
+|e+0#af5f00255&|n|d|c|l|a|s@1| +0#0000000&@66
+@75
+>e+0#af5f00255&|c|h|o| +0#0000000&|T|e|s|t|.|n|e|w|(+0#e000e06&|)| +0#0000000&@59
+@57|2|0|,|1| @9|B|o|t| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_00.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1>v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@62
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|i|m|9| |:|d|e|f| |c|o|m@1|a|n|d| |(|n|e|s|t|e|d|)| +0#0000000&@44
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |'|f|'| +0#0000000&@29
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| |f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|c+0#af5f00255#ffffff0|l|a|s@1| +0#0000000&|T|e|s|t| @62
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|c+0#af5f00255&|o|n|s|t| +0#0000000&|n+0#00e0e07&|a|m|e|:+0#0000000&| |s|t|r|i|n|g| @50
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| |1@1| |l|i|n|e|s|:| |d|e|f| |n|e|w|(|)|-@49
+| @1|e+0#af5f00255#ffffff0|n|d|c|l|a|s@1| +0#0000000&@64
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|T|e|s|t|.|n|e|w|(+0#e000e06&|)| +0#0000000&@57
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_01.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| |f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|c+0#af5f00255#ffffff0|l|a|s@1| +0#0000000&|T|e|s|t| @62
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|c+0#af5f00255&|o|n|s|t| +0#0000000&|n+0#00e0e07&|a|m|e|:+0#0000000&| |s|t|r|i|n|g| @50
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| >+|-@1| |1@1| |l|i|n|e|s|:| |d|e|f| |n|e|w|(|)|-@49
+| @1|e+0#af5f00255#ffffff0|n|d|c|l|a|s@1| +0#0000000&@64
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|T|e|s|t|.|n|e|w|(+0#e000e06&|)| +0#0000000&@57
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|9|,|5|-|1| @7|B|o|t| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_def_nested_fold_99.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1|v+0#af5f00255#ffffff0|i|m|9|s|c|r|i|p|t| +0#0000000&@62
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|i|m|9| |:|d|e|f| |c|o|m@1|a|n|d| |(|n|e|s|t|e|d|)| +0#0000000&@44
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |'|f|'| +0#0000000&@29
+| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| |f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|c+0#af5f00255#ffffff0|l|a|s@1| +0#0000000&|T|e|s|t| @62
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|c+0#af5f00255&|o|n|s|t| +0#0000000&|n+0#00e0e07&|a|m|e|:+0#0000000&| |s|t|r|i|n|g| @50
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| |1@1| |l|i|n|e|s|:| |d|e|f| |n|e|w|(|)|-@49
+| @1|e+0#af5f00255#ffffff0|n|d|c|l|a|s@1| +0#0000000&@64
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1>e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|T|e|s|t|.|n|e|w|(+0#e000e06&|)| +0#0000000&@57
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|2@1|,|1| @9|A|l@1| 
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_01.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_01.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |{|"|F|"|}|{|"|o|"|}|{|"|o|"|}|(|)|-@34
 | +0#0000000#ffffff0@74
-@57|1|9|,|1| @10|8|%| 
+@57|1|9|,|1| @10|6|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_02.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_02.dump
@@ -17,4 +17,4 @@
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |g|:|F|o@1|(|)|-@44
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |s|:|F|o@1|(|)|-@44
-| +0#0000000#ffffff0@56|3|7|,|1| @9|1|8|%| 
+| +0#0000000#ffffff0@56|3|7|,|1| @9|1|4|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_03.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_03.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 @75
 |"+0#0000e05&| |m|o|d|i|f|i|e|r|s| +0#0000000&@63
-@57|5@1|,|0|-|1| @7|2|8|%| 
+@57|5@1|,|0|-|1| @7|2@1|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_04.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_04.dump
@@ -17,4 +17,4 @@
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)| |a|b|o|r|t|-@40
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)| |d|i|c|t|-@41
-| +0#0000000#ffffff0@56|7|3|,|1| @9|4|1|%| 
+| +0#0000000#ffffff0@56|7|3|,|1| @9|3|2|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_05.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_05.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n|!| |F|o@1|(|)| |d|i|c|t|-@40
 | +0#0000000#ffffff0@74
-@57|9|1|,|1| @9|5|4|%| 
+@57|9|1|,|1| @9|4|2|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_06.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_06.dump
@@ -17,4 +17,4 @@
 |++0#0000e05#a8a8a8255|-@1| @1|4| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
-| +0#0000000#ffffff0@56|1|0|9|,|1| @8|6|7|%| 
+| +0#0000000#ffffff0@56|1|0|9|,|1| @8|5|2|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_07.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_07.dump
@@ -17,4 +17,4 @@
 | +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|-@47
 | +0#0000000#ffffff0@74
-@57|1|2|7|,|0|-|1| @6|8|0|%| 
+@57|1|2|7|,|0|-|1| @6|6|3|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_08.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_08.dump
@@ -17,4 +17,4 @@
 |++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
 | +0#0000000#ffffff0@74
 @75
-@57|1|4|5|,|3|-|1| @6|9|5|%| 
+@57|1|4|5|,|3|-|1| @6|7|4|%| 
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_09.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_09.dump
@@ -17,4 +17,4 @@
 |d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| +0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
 |d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n|!| +0#0000000&|F|o@1| @58
 |d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| +0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
-@57|1|6|3|,|7|-|1| @6|9@1|%| 
+@57|1|6|3|,|7|-|1| @6|7|8|%| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_10.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@74
+|"+0#0000e05&| |d|e|l|e|t|e| |f|u|n|c|t|i|o|n| +0#0000000&@57
+@75
+|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| +0#0000000&|F|o@1| @59
+|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| +0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
+>d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n|!| +0#0000000&|F|o@1| @58
+|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| +0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
+@75
+@75
+|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
+@75
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+@57|1|8|1|,|1| @8|9|1|%| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_11.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+>++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|f|u|n|c|t|i|o|n| |F|o@1|(|)|-@45
+| +0#0000000#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|9@1|,|0|-|1| @6|B|o|t| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_12.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+>++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|f|u|n|c|t|i|o|n| |F|o@1|(|)|-@45
+| +0#0000000#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|2|1|7|,|5|-|1| @6|B|o|t| 
--- a/runtime/syntax/testdir/dumps/vim_ex_function_fold_99.dump
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_fold_99.dump
@@ -1,20 +1,20 @@
-|++0#0000e05#a8a8a8255|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|-@47
-| +0#0000000#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|x|,| |y| |=| |4|2|,| |z| |=| |"|z|e|d|"|)|-@26
+|d+0#af5f00255#ffffff0|e|l|f|u|n|c|t|i|o|n| +0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
+@75
+@75
+|"+0#0000e05&| |f|o|l|d|-|r|e|g|i|o|n| |e|n|d|i|n|g| +0#0000000&@54
+@75
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
 | +0#0000000#ffffff0@74
-|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|-@47
+|++0#0000e05#a8a8a8255|-@1| @1|3| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
 | +0#0000000#ffffff0@74
-@75
-|"+0#0000e05&| |c|o|m@1|e|n|t|s| +0#0000000&@64
-@75
+|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
 |++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
 | +0#0000000#ffffff0@74
-@75
-|"+0#0000e05&| |d|e|l|e|t|e| |f|u|n|c|t|i|o|n| +0#0000000&@57
-@75
-|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| +0#0000000&|F|o@1| @59
-|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| +0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
-|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n|!| +0#0000000&|F|o@1| @58
-|d+0#af5f00255&|e|l|f|u|n|c|t|i|o|n| +0#0000000&|f|o@1|.+0#af5f00255&|b+0#0000000&|a|r| @55
-> @74
-@57|1|8|3|,|0|-|1| @6|B|o|t| 
+|++0#0000e05#a8a8a8255|-@1| @1|6| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|5| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|o@1|(|)|-@46
+| +0#0000000#ffffff0@74
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |:|f|u|n|c|t|i|o|n| |F|o@1|(|)|-@45
+> +0#0000000#ffffff0@74
+@57|2@1|3|,|0|-|1| @6|B|o|t| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_00.dump
@@ -0,0 +1,20 @@
+>"+0#0000e05#ffffff0| |V|i|m| |:|d|e|f| |a|n|d| |:|f|u|n|c|t|i|o|n| |c|o|m@1|a|n|d|s| |(|n|e|s|t|e|d|)| +0#0000000&@32
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|u|n|A|(+0#e000e06&|)|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@56
+@4|d+0#af5f00255&|e|f| +0#0000000&|D|o|F|u|n|A|(+0#e000e06&|)|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@50
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.|"| +0#0000000&@56
+@4|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@64
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|A|(+0#e000e06&|)| +0#0000000&@55
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|d+0#af5f00255&|e|f| +0#0000000&|F|u|n|B|(+0#e000e06&|)|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@56
+@4|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|D|o|F|u|n|B|(+0#e000e06&|)| +0#0000000&@53
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.@1|"| +0#0000000&@55
+@4|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@59
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|B|(+0#e000e06&|)| +0#0000000&@55
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@59
+@57|1|,|1| @10|T|o|p| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_01.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@3|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@59
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|B|(+0#e000e06&|)| +0#0000000&@55
+|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@68
+@75
+>f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@59
+@4|d+0#af5f00255&|e|f| +0#0000000&|D|o|F|u|n|C|(+0#e000e06&|)|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@50
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.@2|"| +0#0000000&@54
+@4|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@64
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|C|(+0#e000e06&|)| +0#0000000&@55
+|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@63
+@75
+|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@59
+@4|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|D|o|F|u|n|D|(+0#e000e06&|)| +0#0000000&@53
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.@3|"| +0#0000000&@53
+@4|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@59
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|D|(+0#e000e06&|)| +0#0000000&@55
+@57|1|9|,|1| @9|6|8|%| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_99.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@3|d+0#af5f00255&|e|f| +0#0000000&|D|o|F|u|n|C|(+0#e000e06&|)|:+0#0000000&| |s+0#00e0003&|t|r|i|n|g| +0#0000000&@50
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.@2|"| +0#0000000&@54
+@4|e+0#af5f00255&|n|d@1|e|f| +0#0000000&@64
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|C|(+0#e000e06&|)| +0#0000000&@55
+|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@63
+@75
+|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@59
+@4|f+0#af5f00255&|u|n|c|t|i|o|n| +0#0000000&|D|o|F|u|n|D|(+0#e000e06&|)| +0#0000000&@53
+@8|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|"+0#e000002&|.@3|"| +0#0000000&@53
+@4|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@59
+@75
+@4|r+0#af5f00255&|e|t|u|r|n| +0#0000000&|D|o|F|u|n|D|(+0#e000e06&|)| +0#0000000&@55
+|e+0#af5f00255&|n|d|f|u|n|c|t|i|o|n| +0#0000000&@63
+@75
+|e+0#af5f00255&|c|h|o| +0#0000000&|F|u|n|A|(+0#e000e06&|)| +0#0000000&@63
+|e+0#af5f00255&|c|h|o| +0#0000000&|F|u|n|B|(+0#e000e06&|)| +0#0000000&@63
+|e+0#af5f00255&|c|h|o| +0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@63
+>e+0#af5f00255&|c|h|o| +0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@63
+@57|3|8|,|1| @9|B|o|t| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_00.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1>"+0&#ffffff0| |V|i|m| |:|d|e|f| |a|n|d| |:|f|u|n|c|t|i|o|n| |c|o|m@1|a|n|d|s| |(|n|e|s|t|e|d|)| +0#0000000&@30
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |'|f|'| +0#0000000&@29
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| |f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|A|(|)|:| |s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|B|(|)|:| |s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|u|n|C|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|u|n|D|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|A|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|B|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@61
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_01.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |'|f|'| +0#0000000&@29
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| |f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|A|(|)|:| |s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| >+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|B|(|)|:| |s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|u|n|C|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|u|n|D|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|A|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|B|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@61
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|9|,|1| @9|B|o|t| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_02.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|u|n|C|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|u|n|D|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1>e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|A|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|B|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@61
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|3|7|,|1| @9|B|o|t| 
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/vim_ex_function_nested_fold_99.dump
@@ -0,0 +1,20 @@
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|i|m| |:|d|e|f| |a|n|d| |:|f|u|n|c|t|i|o|n| |c|o|m@1|a|n|d|s| |(|n|e|s|t|e|d|)| +0#0000000&@30
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|v|i|m|s|y|n|_|f|o|l|d|i|n|g| |=| |'|f|'| +0#0000000&@29
+| +0#0000e05#a8a8a8255@1|"+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l| |f|d|c|=|2| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@34
+| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|A|(|)|:| |s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |d|e|f| |F|u|n|B|(|)|:| |s|t|r|i|n|g|-@40
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|u|n|C|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+|++0#0000e05#a8a8a8255| |+|-@1| @1|7| |l|i|n|e|s|:| |f|u|n|c|t|i|o|n| |F|u|n|D|(|)|-@43
+| @1| +0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|A|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|B|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1|e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|C|(+0#e000e06&|)| +0#0000000&@61
+| +0#0000e05#a8a8a8255@1>e+0#af5f00255#ffffff0|c|h|o| +0#0000000&|F|u|n|D|(+0#e000e06&|)| +0#0000000&@61
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|4|0|,|1| @9|A|l@1| 
--- a/runtime/syntax/testdir/input/vim_ex_def_fold.vim
+++ b/runtime/syntax/testdir/input/vim_ex_def_fold.vim
@@ -108,3 +108,23 @@ def Foo()
   "useless string"
 enddef
 
+
+" fold-region ending
+
+def Foo()
+  # enddef
+enddef
+
+def Foo()
+  echo "enddef"
+enddef
+
+def Foo()
+  let x =<< END
+    endfunction
+  END
+enddef
+
+:def Foo()
+:enddef
+
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_def_nested.vim
@@ -0,0 +1,20 @@
+vim9script
+# Vim9 :def command (nested)
+
+class Test
+    const name: string
+
+    def new()
+	def Name(): string
+	    function GiveName()
+		return "any"
+	    endfunction
+
+	    return GiveName()
+	enddef
+
+	this.name = Name()
+    enddef
+endclass
+
+echo Test.new()
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_def_nested_fold.vim
@@ -0,0 +1,22 @@
+vim9script
+# Vim9 :def command (nested)
+# VIM_TEST_SETUP let g:vimsyn_folding = 'f'
+# VIM_TEST_SETUP setl fdc=2 fdm=syntax
+
+class Test
+    const name: string
+
+    def new()
+	def Name(): string
+	    function GiveName()
+		return "any"
+	    endfunction
+
+	    return GiveName()
+	enddef
+
+	this.name = Name()
+    enddef
+endclass
+
+echo Test.new()
--- a/runtime/syntax/testdir/input/vim_ex_function_fold.vim
+++ b/runtime/syntax/testdir/input/vim_ex_function_fold.vim
@@ -181,3 +181,43 @@ delfunction foo.bar
 delfunction! Foo
 delfunction foo.bar
 
+
+" fold-region ending
+
+function Foo()
+  " endfunction
+endfunction
+
+function Foo()
+  echo "endfunction"
+endfunction
+
+function Foo()
+  let x =<< END
+    endfunction
+  END
+
+endfunction
+
+function Foo()
+  append
+    endfunction
+.
+endfunction
+
+function Foo()
+  change
+    endfunction
+.
+
+endfunction
+
+function Foo()
+  insert
+    endfunction
+.
+endfunction
+
+:function Foo()
+:endfunction
+
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_function_nested.vim
@@ -0,0 +1,38 @@
+" Vim :def and :function commands (nested)
+
+def FunA(): string
+    def DoFunA(): string
+	return "."
+    enddef
+
+    return DoFunA()
+enddef
+
+def FunB(): string
+    function DoFunB()
+	return ".."
+    endfunction
+
+    return DoFunB()
+enddef
+
+function FunC()
+    def DoFunC(): string
+	return "..."
+    enddef
+
+    return DoFunC()
+endfunction
+
+function FunD()
+    function DoFunD()
+	return "...."
+    endfunction
+
+    return DoFunD()
+endfunction
+
+echo FunA()
+echo FunB()
+echo FunC()
+echo FunD()
new file mode 100644
--- /dev/null
+++ b/runtime/syntax/testdir/input/vim_ex_function_nested_fold.vim
@@ -0,0 +1,40 @@
+" Vim :def and :function commands (nested)
+" VIM_TEST_SETUP let g:vimsyn_folding = 'f'
+" VIM_TEST_SETUP setl fdc=2 fdm=syntax
+
+def FunA(): string
+    def DoFunA(): string
+	return "."
+    enddef
+
+    return DoFunA()
+enddef
+
+def FunB(): string
+    function DoFunB()
+	return ".."
+    endfunction
+
+    return DoFunB()
+enddef
+
+function FunC()
+    def DoFunC(): string
+	return "..."
+    enddef
+
+    return DoFunC()
+endfunction
+
+function FunD()
+    function DoFunD()
+	return "...."
+    endfunction
+
+    return DoFunD()
+endfunction
+
+echo FunA()
+echo FunB()
+echo FunC()
+echo FunD()
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -228,9 +228,9 @@ syn cluster vimExprList contains=vimEnvv
 "   (buftype != nofile test avoids having append, change, insert show up in the command window)
 " =======================
 if &buftype != 'nofile'
- syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$"		matchgroup=vimCommand end="^\.$""
- syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$"		matchgroup=vimCommand end="^\.$""
- syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$"		matchgroup=vimCommand end="^\.$""
+ syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$"		matchgroup=vimCommand end="^\.$" extend
+ syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$"		matchgroup=vimCommand end="^\.$" extend
+ syn region vimInsert	matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$"		matchgroup=vimCommand end="^\.$" extend
 endif
 
 " Behave! {{{2
@@ -281,12 +281,14 @@ if !exists("g:vimsyn_noerror") && !exist
  syn match	vimOperError	")"
 endif
 
-" Functions : Tag is provided for those who wish to highlight tagged functions {{{2
+" Functions: Tag is provided for those who wish to highlight tagged functions {{{2
 " =========
 syn cluster	vimFuncList	contains=vimFuncBang,vimFunctionError,vimFuncKey,vimFuncSID,Tag
 syn cluster	vimDefList	contains=vimFuncBang,vimFunctionError,vimDefKey,vimFuncSID,Tag
-syn cluster	vimFuncBodyList	contains=@vimCmdList,vimCmplxRepeat,vimComment,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimFuncVar,vimLetHereDoc,vimLineComment,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst
-syn cluster	vimDefBodyList	contains=@vimCmdList,vimCmplxRepeat,vim9Comment,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vim9LineComment,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegion,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst
+
+syn cluster	vimFuncBodyCommon	contains=@vimCmdList,vimCmplxRepeat,vimContinue,vimCtrlChar,vimDef,vimEnvvar,vimFBVar,vimFunc,vimFunction,vimLetHereDoc,vimNotation,vimNotFunc,vimNumber,vimOper,vimOperParen,vimRegister,vimSearch,vimSpecFile,vimString,vimSubst,vimFuncFold
+syn cluster	vimFuncBodyList	contains=@vimFuncBodyCommon,vimComment,vimLineComment,vimFuncVar,vimInsert
+syn cluster	vimDefBodyList	contains=@vimFuncBodyCommon,vim9Comment,vim9LineComment
 
 syn region	vimFuncPattern	contained		matchgroup=vimOper start="/" end="$" contains=@vimSubstList
 syn match	vimFunction	"\<fu\%[nction]\>"	skipwhite nextgroup=vimCmdSep,vimComment,vimFuncPattern contains=vimFuncKey
@@ -321,9 +323,9 @@ syn match	vimEndfunction	"\<endf\%[uncti
 syn match	vimEnddef	"\<enddef\>"
 
 if exists("g:vimsyn_folding") && g:vimsyn_folding =~# 'f'
- syn region	vimFuncFold	start="\<fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*("	end="\<endf\%[unction]\>" contains=vimFunction fold keepend transparent
- syn region	vimFuncFold	start="\<def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\)\+("		end="\<enddef\>"	        contains=vimDef      fold keepend transparent
- syn region	vimFuncFold	start="\<def\s\+new\i\+("				end="\<enddef\>"	        contains=vimDef      fold keepend transparent
+ syn region	vimFuncFold	start="^\s*:\=\s*fu\%[nction]\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\|{.\{-1,}}\)\+\s*("	end="^\s*:\=\s*endf\%[unction]\>" contains=vimFunction fold keepend extend transparent
+ syn region	vimFuncFold	start="^\s*:\=\s*def\>!\=\s*\%(<[sS][iI][dD]>\|[sg]:\)\=\%(\i\|[#.]\)\+("		end="^\s*:\=\s*enddef\>"          contains=vimDef      fold keepend extend transparent
+ syn region	vimFuncFold	start="^\s*:\=\s*def\s\+new\i\+("					end="^\s*:\=\s*enddef\>"          contains=vimDef      fold keepend extend transparent
 endif
 
 syn match	vimFuncVar   contained	"a:\%(\K\k*\|\d\+\)\>"
@@ -540,7 +542,7 @@ syn keyword	vimUnlet	unl[et]		skipwhite 
 syn match	vimUnletBang	contained	"!"	skipwhite nextgroup=vimUnletVars
 syn region	vimUnletVars	contained	start="$\I\|\h" skip="\n\s*\\" end="$" end="|" contains=vimVar,vimEnvvar,vimContinue,vimString,vimNumber
 
-VimFoldh syn region vimLetHereDoc	matchgroup=vimLetHereDocStart start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\s*\z1\s*$'
+VimFoldh syn region vimLetHereDoc	matchgroup=vimLetHereDocStart start='=<<\s*\%(trim\s\+\%(eval\s\+\)\=\|eval\s\+\%(trim\s\+\)\=\)\=\z(\L\S*\)' matchgroup=vimLetHereDocStop end='^\s*\z1\s*$' extend
 syn keyword	vimLet	var		skipwhite nextgroup=vimVar,vimFuncVar,vimLetHereDoc
 
 " For: {{{2