+++ /dev/null
-"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"
-" 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
-
" 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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 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>