From ecc0520cf1e53bc5c288dcf01b13c6c9b1367a23 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 9 Jun 2025 11:01:26 +0100 Subject: [PATCH] etc/vim/source/map.vim --- etc/vim/source/map.vim | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/etc/vim/source/map.vim b/etc/vim/source/map.vim index bb1245de..6400264b 100644 --- a/etc/vim/source/map.vim +++ b/etc/vim/source/map.vim @@ -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 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -- 2.47.3