gJ combination does this; from
Join [count] lines, with a minimum of two lines. Don't insert or remove any spaces.
You could rebind it to
J, if you wanted to save a keystroke:
:nnoremap J gJ
Note that this doesn't remove any spaces, so if either the current line ends
with a space or next line starts with one or more spaces, they will be left as
We could use
Jx in this case, then it will be
Helloworld, but that won't work in all cases; from the help:
Join the highlighted lines, with a minimum of two lines. Remove the indent and insert up to two
These commands, except "gJ", insert one space in place of the unless
there is trailing white space or the next line starts with a ')'.
So in some cases more than one space or no space is inserted. As far as I can
see, there is no easy way to change this behaviour; I created a function to
gJ to always join without spaces:
" Like gJ, but always remove spaces
execute 'normal gJ'
" Character under cursor is whitespace?
if matchstr(getline('.'), '\%' . col('.') . 'c.') =~ '\s'
" When remove it!
execute 'normal dw'
" Map it to a key
nnoremap <Leader>J :call JoinSpaceless()<CR>