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()
" 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
"
" 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
"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