Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opposite of newline in vim

Tags:

vim

In vim, is there a command to delete the newline, and all empty space behind the cursor?

Say I stand in the middle of a text in insert mode and press Enter, what command would the reverse what I just did?

A) An example:

"some code{ in here }"

B) After pressing Enter:

"some code{
   in here }"

Now pressing backspace will delete one space of the indentation. I would rather have it delete all indentation, and jump back to A.

Can this be done in a command or by doing some remapping to the backspace key?

like image 846
mollerhoj Avatar asked Dec 04 '22 12:12

mollerhoj


1 Answers

It's tragic how unknown the J command is. It joins lines in normal mode.

In insert mode, you can press <C-U> twice; first, it'll delete the indent before the cursor, then it'll join with the previous line. Note that this requires

:set backspace=indent,eol,start
like image 113
Ingo Karkat Avatar answered Feb 27 '23 14:02

Ingo Karkat