Join lines exactly
gJ
Example
Normal mode on foo. Next line: .bar.
foo
.barCursor on line 1, column 1- gJ foo.bar · joined without an added space
foo.barCursor on line 1, column 4Details & Vim help
Join the next line without inserting or deleting boundary whitespace.
Reassemble a token that was split across lines.
Unlike J, gJ does not add a separating space or remove the next line’s leading whitespace. Existing indentation therefore stays in the joined text.
Try it in Vim
- Put the cursor on the first line.
- Press gJ.
- Use a count, such as 3gJ, to join more lines.