Say I want to edit the following line:
var myVar =
"I am a string!";
So that it looks like this:
var myVar = "I am a string!";
Is there a movement that goes to the end of the previous line?
d<leftArrow> will delete current and left character. d$ will delete from current position to end of line. d^ will delete from current backward to first non-white-space character. d0 will delete from current backward to beginning of line.
Cutting (Deleting) dd - Delete (cut) the current line, including the newline character. 3dd - Delete (cut) three lines, starting from the line where the cursor is positioned, d$ - Delete (cut) everything from the cursor to the end of the line.
What you want is the line join command, J.
In normal mode, put your cursor anywhere on the var myVar =
line and type J (capital j).
Direction-wise motions work with J - 5J indents 5 lines below the cursor, etc. You can also select a range of lines using visual mode (v to start visual mode selection) and join them all into one using J.
The &joinspaces
option affects this behavior as well. When it's "on" (set joinspaces
or set js
) it adds two spaces after a sentence-ending mark (i.e. '.', '?', or '!') when joining lines. set nojoinspaces
or set nojs
to turn that off and insert only one space.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With