]> git.nbdom.net Git - nb.git/commitdiff
Add global MapHelp
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 21 Mar 2023 00:01:18 +0000 (01:01 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 21 Mar 2023 00:01:18 +0000 (01:01 +0100)
etc/vim/source/comment.vim [deleted file]
etc/vim/source/map.vim
etc/vim/source/option.vim

diff --git a/etc/vim/source/comment.vim b/etc/vim/source/comment.vim
deleted file mode 100644 (file)
index 4b1cd94..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"
-" Functions
-" NB 12.12.22: Functions to comment texts  
-"
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-if exists("_loaded_comment")
-  finish
-endif
-let _loaded_comment = 1
-
-
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-" Global
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-let $USER_INITIALS = system('printf "%s" ${USER_INITIALS:-`whoami`}')
-func! CommentMeNow()
-       return $USER_INITIALS . ' ' . strftime('%d.%m.%y')
-endfunc
-
-func! CommentSubSpecialChar(text)
-" NB 12.12.22: Substitute specials char like \n in an array  
-       let i = 0
-       let val = ''
-       for val in a:text
-         let a:text[i] = substitute(val,'\\n',"\n",'')
-               let i += 1
-       endfor
-endfunc
-
-func! CommentNewLine()
-" NB 12.12.22: Create a new line of comment  
-       if ( g:mimeComment->get(FileType()) == '0')
-         let comment = '#'
-               " NB 12.12.22 return Err('No comment defined for filetype '.FileType())
-       else
-               let comment = g:mimeComment->get(FileType())
-       endif
-       let comment = split(comment,'\s\+')
-       call CommentSubSpecialChar(comment)
-
-  " Beginning of line
-       let new_line = comment[0].' '.CommentMeNow().': foo '
-
-  " End of line
-       if ( len(comment)>1 )
-         let new_line = new_line . comment[1]
-       endif
-
-       exec "normal! o".new_line."\<esc>?foo\<cr>cw "
-       exec "startinsert"
-       " exec "cw"
-endfunc
-
-func! CommentToggle()
-" NB 12.12.22: Toggle current line between commented / not commented  
-       if ( g:mimeComment->get(FileType()) == '0')
-         let comment = '#'
-               " NB 12.12.22 return Err('No comment defined for filetype '.FileType())
-       else
-               let comment = g:mimeComment->get(FileType())
-       endif
-
-       let comment = split(comment,'\s\+')
-       " call CommentSubSpecialChar(comment)
-
-       let curr_line = getline('.')
-       "
-       " Wipe out existing comment
-  "
-  " Beginning of line
-       let new_line = substitute(curr_line,'^\([\t ]*\)'.comment[0].' [^ ]\+ \d\d\.\d\d\.\d\d:\? ','\1','')
-  " End of line
-       if ( len(comment)>1 )
-         let new_line = substitute(new_line,'\s*'.comment[1].'\s*$','','')
-       endif
-
-       if new_line == curr_line
-         "
-         " Add comment
-    "
-  " NB 11.12.22 let v = ''
-  " NB 11.12.22 let v = ''
-    " Beginning of line
-         let new_line = substitute(curr_line,'^\([\t ]*\)','\1'.comment[0].' '.CommentMeNow().' ','')
-    " End of line
-         if ( len(comment)>1 )
-           let new_line = substitute(new_line,'\s*$',' '.comment[1],'')
-         endif
-         " let new_line = substitute(new_line,'\\n',"\n",'')
-       endif
-
-       call setline('.',new_line)
-endfunc
-
index 3ede584357dcc0fe4a448d6804b4a2bd99b0f836..edc868420a57b695b8e38934f3c9f78e8dc8eb03 100644 (file)
@@ -8,6 +8,104 @@
 " See: http://vimdoc.sourceforge.net/htmldoc/insert.html
 "
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+let MapHelp = []
+func!MapHelp()
+  let i=0
+  let line=['','']
+  let fcount=''
+  for line in g:MapHelp
+    if len(line[0]) > fcount
+      let fcount = len(line[0])
+    endif
+    " echo len(line[0])
+  endfor
+  " echo fcount
+
+       let fmt=" %-" . fcount . "s : %s"
+       echo "Help:\n"
+  for line in g:MapHelp
+         echo printf(fmt,line[0],line[1])
+  endfor
+endfunc
+
+func! CommentMeNow()
+       return $USER_INITIALS . ' ' . strftime('%d.%m.%y')
+endfunc
+
+func! CommentSubSpecialChar(text)
+" NB 12.12.22: Substitute specials char like \n in an array  
+       let i = 0
+       let val = ''
+       for val in a:text
+         let a:text[i] = substitute(val,'\\n',"\n",'')
+               let i += 1
+       endfor
+endfunc
+
+func! CommentNewLine()
+" NB 12.12.22: Create a new line of comment  
+       if ( g:mimeComment->get(FileType()) == '0')
+         let comment = '#'
+               " NB 12.12.22 return Err('No comment defined for filetype '.FileType())
+       else
+               let comment = g:mimeComment->get(FileType())
+       endif
+       let comment = split(comment,'\s\+')
+       call CommentSubSpecialChar(comment)
+
+  " Beginning of line
+       let new_line = comment[0].' '.CommentMeNow().': foo '
+
+  " End of line
+       if ( len(comment)>1 )
+         let new_line = new_line . comment[1]
+       endif
+
+       exec "normal! o".new_line."\<esc>?foo\<cr>cw "
+       exec "startinsert"
+       " exec "cw"
+endfunc
+
+func! CommentToggle()
+" NB 12.12.22: Toggle current line between commented / not commented  
+       if ( g:mimeComment->get(FileType()) == '0')
+         let comment = '#'
+               " NB 12.12.22 return Err('No comment defined for filetype '.FileType())
+       else
+               let comment = g:mimeComment->get(FileType())
+       endif
+
+       let comment = split(comment,'\s\+')
+       " call CommentSubSpecialChar(comment)
+
+       let curr_line = getline('.')
+       "
+       " Wipe out existing comment
+  "
+  " Beginning of line
+       let new_line = substitute(curr_line,'^\([\t ]*\)'.comment[0].' [^ ]\+ \d\d\.\d\d\.\d\d:\? ','\1','')
+  " End of line
+       if ( len(comment)>1 )
+         let new_line = substitute(new_line,'\s*'.comment[1].'\s*$','','')
+       endif
+
+       if new_line == curr_line
+         "
+         " Add comment
+    "
+  " NB 11.12.22 let v = ''
+  " NB 11.12.22 let v = ''
+    " Beginning of line
+         let new_line = substitute(curr_line,'^\([\t ]*\)','\1'.comment[0].' '.CommentMeNow().' ','')
+    " End of line
+         if ( len(comment)>1 )
+           let new_line = substitute(new_line,'\s*$',' '.comment[1],'')
+         endif
+         " let new_line = substitute(new_line,'\\n',"\n",'')
+       endif
+
+       call setline('.',new_line)
+endfunc
 
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 "
@@ -20,14 +118,17 @@ map <C-b> :bp<C-M>
 
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 " F1 - Last Cmd
+call add(MapHelp,['F1, Alt+x','Last shell command executed'])
 map <F1> :!<C-UP><C-M>
 map \ex :!<C-UP><C-M>
 
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 " F2 - Script, formated text verification
+call add(MapHelp,['F2','Check syntaxe'])
 map <F2> :call FileCheckSyntaxe()<CR>
 
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 " F5 - Comment
+call add(MapHelp,['F5','Add / Delete comment'])
 map <F5> :call CommentNewLine()<CR>
 vmap <F5> :call CommentToggle()<CR>
index 5cf9dce1121e3840df7031227d752f5441a6916c..c5c4ebc5bc97a81aebd96dca938f833c1d65dccd 100644 (file)
@@ -8,6 +8,8 @@
 "
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
+let $USER_INITIALS = system('printf "%s" ${USER_INITIALS:-`whoami`}')
+
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 " Syntax highlighting only for enhanced-vi
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""