From aca9ed12f768901d83ad6dc4be92a39ff4995eef Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 21 Mar 2023 22:01:24 +0100 Subject: [PATCH] _MapHelpSort --- etc/vim/source/map.vim | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/etc/vim/source/map.vim b/etc/vim/source/map.vim index d84630e9..c3f985b9 100644 --- a/etc/vim/source/map.vim +++ b/etc/vim/source/map.vim @@ -9,9 +9,15 @@ " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let MapHelp = [] +func!_MapHelpSort(x,y) + if (a:x[0] == a:y[0]) + return 0 + endif + return a:x[0] > a:y[0] ? 1 : -1 +endfunc + func!MapHelp() let line=['',''] - let klines=[] let fcount='' " Calculate string length for sprintf @@ -19,16 +25,15 @@ func!MapHelp() if len(line[0]) > fcount let fcount = len(line[0]) endif - call add(klines,line[0]) " for sorting later endfor - call sort(klines) + call sort(g:MapHelp,function("_MapHelpSort")) let fmt=" %-" . fcount . "s : %s" let i=0 echo "Help:\n" - for line in klines - echo printf(fmt,g:MapHelp[i][0],g:MapHelp[i][1]) + for line in g:MapHelp + echo printf(fmt,line[0],line[1]) let i = i+1 endfor @@ -138,3 +143,9 @@ map :call FileCheckSyntaxe() call add(MapHelp,['F5','Add / Delete comment']) map :call CommentNewLine() vmap :call CommentToggle() + +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Alt+h - Help +call add(MapHelp,['Alt+h','This Help']) +map ˙ :call MapHelp() +map h :call MapHelp() -- 2.47.3