]> git.nbdom.net Git - nb.git/commitdiff
etc/vim/source/map.vim
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 24 Jun 2025 07:46:23 +0000 (08:46 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 24 Jun 2025 07:46:23 +0000 (08:46 +0100)
etc/vim/source/map.vim

index 6400264b4f330567c1eae15ad1d53ed3b3dd11f2..77e8540ed52d50bead1c88c2449ae4ffac3266b8 100644 (file)
@@ -43,16 +43,21 @@ func!MapHelp()
 endfunc
 
 function! InsertMultiline(multiline_text) abort
-    " Split the input at newlines, handling both Unix (\n) and Windows (\r\n) formats
-    let lines = split(a:multiline_text, '\r\n\|\n')
-    
-    " Replace current line with first line
-    call setline('.', lines[0])
-    
-    " Append remaining lines if they exist
-    if len(lines) > 1
-        call append('.', lines[1:])
-    endif
+
+       " Split the input at newlines, handling both Unix (\n) and Windows (\r\n) formats
+       let lines = split(a:multiline_text, '\r\n\|\n')
+  " Handle empty input gracefully
+       if empty(lines)
+               let lines = ['']
+       endif
+
+       " Replace current line with first line
+       call setline('.', lines[0])
+
+       " Append remaining lines if they exist
+       if len(lines) > 1
+               call append('.', lines[1:])
+       endif
 endfunction
 
 func! CommentMeNow()
@@ -98,7 +103,6 @@ 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
@@ -122,8 +126,6 @@ func! CommentToggle()
          "
          " 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
@@ -133,6 +135,11 @@ func! CommentToggle()
          "let new_line = substitute(new_line,'\n',"\n",'g')
        endif
 
+       " NB 24.06.25 if (empty(new_line))
+               " NB 24.06.25 let new_line = ''
+       " NB 24.06.25 endif
+
+       "echo new_line
        call InsertMultiline(new_line)
        " NB 09.06.25 call setline('.',new_line)
 endfunc