]> git.nbdom.net Git - nb.git/commitdiff
/opt/nb/etc/vim/source/comment.vim created
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 12 Dec 2022 19:50:47 +0000 (20:50 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 12 Dec 2022 19:50:47 +0000 (20:50 +0100)
etc/vim/source/comment.vim [new file with mode: 0644]
etc/vim/source/functions.vim

diff --git a/etc/vim/source/comment.vim b/etc/vim/source/comment.vim
new file mode 100644 (file)
index 0000000..8ad4a7e
--- /dev/null
@@ -0,0 +1,84 @@
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+"
+" Functions
+" NB 12.12.22: Functions to comment texts  
+"
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+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
+
+       " NB 12.12.22 let g:File['path'] = expand('%:p')
+       " NB 12.12.22 let g:File['ext'] = expand('%:e')
+       " NB 12.12.22 let g:File['type'] = &filetype
+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].' '.MeNow().': 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].' '.MeNow().' ','')
+    " 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 b8259ed0d36744485cd69dcd1efd62e1924a6e17..459c25bd5b2c6afcb3b36e2fc11df99958800fbb 100644 (file)
@@ -151,81 +151,6 @@ function Err(txt)
   return
 endfunc
 
-func! SubSpecialChar(c)
-" NB 12.12.22: Substitute specials char like \n in an array  
-       let i = 0
-       let val = ''
-       for val in a:c
-         let a:c[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 SubSpecialChar(comment)
-
-  " Beginning of line
-       let new_line = comment[0].' '.MeNow().': 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 SubSpecialChar(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].' '.MeNow().' ','')
-    " 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
-
 
 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 let Debug = $VIMRC_DEBUG