In Normal mode, you can join lines using J and gJ commands. These differ in how the end-of-line character and indentation at the start of lines being joined are handled.

  • J joins the current line and the next line
    • the deleted <EOL> character is replaced with a space (unless there are trailing spaces or the next line starts with a ) character)
    • indentation from the lines being joined are removed, except the current line
  • 3J joins the current line and next two lines with one space in between the lines
  • gJ joins the current line and the next line
    • <EOL> character is deleted (space character won't be added)
    • indentation won't be removed

info joinspaces, cpoptions and formatoptions settings will affect the behavior of these commands. See :h J and scroll down for more details.

Video demo:


info See also my Vim Reference Guide and curated list of resources for Vim.