Vim Recall繁體中文

Join lines exactly

gJ

Example

Normal mode on foo. Next line: .bar.

Before
foo
.bar
Cursor on line 1, column 1
  1. gJ foo.bar · joined without an added space
After
foo.bar
Cursor on line 1, column 4
Details & 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

  1. Put the cursor on the first line.
  2. Press gJ.
  3. Use a count, such as 3gJ, to join more lines.