]> git.nbdom.net Git - nb.git/commitdiff
etc/vim/source/map.vim
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 9 Jun 2025 10:01:26 +0000 (11:01 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 9 Jun 2025 10:01:26 +0000 (11:01 +0100)
etc/vim/source/map.vim

index bb1245deda9501e515a7ccae90dfcf08a5bdf384..6400264b4f330567c1eae15ad1d53ed3b3dd11f2 100644 (file)
@@ -42,6 +42,19 @@ 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
+endfunction
+
 func! CommentMeNow()
        return $USER_INITIALS . ' ' . strftime('%d.%m.%y')
 endfunc
@@ -91,8 +104,6 @@ func! CommentToggle()
        endif
 
        let comment = split(comment,'\s\+')
-       " NB 09.06.25: For css  
-       " let comment = substitute(comment,'\n','\r','g')
        "call CommentSubSpecialChar(comment)
 
        let curr_line = getline('.')
@@ -122,7 +133,8 @@ func! CommentToggle()
          "let new_line = substitute(new_line,'\n',"\n",'g')
        endif
 
-       call setline('.',new_line)
+       call InsertMultiline(new_line)
+       " NB 09.06.25 call setline('.',new_line)
 endfunc
 
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""