From: Nicolas Boisselier Date: Mon, 9 Jun 2025 10:01:26 +0000 (+0100) Subject: etc/vim/source/map.vim X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=ecc0520cf1e53bc5c288dcf01b13c6c9b1367a23;p=nb.git etc/vim/source/map.vim --- 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 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""