How do I join a specific number of lines at once without pressing J multiple times?
{count}J
The J command joins the current line with the line below, adding a space between them.
17 results for "join lines J"
{count}J
The J command joins the current line with the line below, adding a space between them.
J (in visual mode)
In visual mode, pressing J joins all selected lines into a single line with spaces between them.
J
The J command joins the current line with the line below it, replacing the newline with a space.
qaJjq
Record a macro that joins the current line with the next using J, then moves down one line with j.
gJ
The gJ command joins the current line with the line below it without inserting any space between them.
vipJ
When text is hard-wrapped for readability in git diffs or markdown source, you sometimes need the paragraph as a single line for refactoring, search, or export.
:[range]join
The :[range]join Ex command lets you join lines by specifying an explicit line range — without having to navigate there or use visual selection.
:%s/\n/ /g
Using \n in the pattern of :substitute matches the newline character at the end of each line, letting you join lines with any separator you choose — something
:'<,'>s/\n/, /g
Vim's J command joins lines with a single space, but sometimes you need a custom separator like a comma, pipe, or semicolon.
editing #editing #ex-commands #visual-mode #substitution #lines
:set nojoinspaces
By default, Vim follows an old typesetting convention and inserts two spaces after a period, exclamation mark, or question mark when joining lines with J.
:g/./,/^$/join
Hard-wrapped text (where each sentence is on its own line) is common in commit messages, email threads, and older documentation.
gS / gJ
The splitjoin.
plugins #plugins #splitjoin #editing #refactoring #formatting
:g/^$/,/./-j
The command :g/^$/,/.
:s/\n/ /
One of the most confusing asymmetries in Vim's substitution syntax: \n and \r mean different things depending on whether they appear in the pattern or the repla
:set formatoptions
The formatoptions setting is a string of single-character flags that governs Vim's automatic text formatting: when lines wrap, whether comment syntax continues
:g/start/,/end/d
The :g (global) command can operate on ranges, not just single lines.
:undojoin
When writing Vim scripts or running multiple Ex commands, each command normally creates a separate undo entry.