visualrun.vim (593B)
1 if exists('g:loaded_visualrun_autoload') 2 finish 3 endif 4 let g:loaded_visualrun_autoload = 1 5 6 function! visualrun#JoinSelection() abort 7 try 8 " Get selected text (restore @x in the 'finally' block) 9 let x_save = @x 10 silent! normal! gv"xy 11 12 " Split & prepare the lines 13 let lines = @x->split('\v'."\n".'(\s*\\)@!') 14 call map(lines, 'substitute(v:val, "\\v\\n\\s*\\", "", "g")') 15 call filter(lines, 'v:val !~ "^\s*$"') 16 17 " All lines will be executed as one command 18 return lines->join("\n") 19 finally 20 " Restore previous @x 21 let @x = x_save 22 endtry 23 endfunction