0

i got some situation like this (in normal mode)

 ... \} ] 

i want to make it

 ... \}] 

my way is use i to insert before the ] and then ctrl+w or backspace to delete the CR.

is there a more efficient way to make this change?(like cursor on the } and delete CR after it?)

thanks!

4 Answers 4

4

maybe this way:

go to the second line

press gJ

Sign up to request clarification or add additional context in comments.

1 Comment

wow!this is exactly what i want,the <kbd>g</kbd> is really powerful,thanks!
2

If you don't mind the extra space, it's very simple. While you are on the line with \}, you just press J. It doesn't matter where you are on the line, it will join the next line with it and delimit with a space and place the cursor at the space. If you don't want the space, press x then you're done.

So just J if you want the space, or Jx without space and you can start anywhere on the \} line.

2 Comments

I don't think Jx works. I think it deletes the wrong char. You are right about anywhere on the line, though.
@Jim, in vim version 7.3 it does the correct character (I tried it on several different cases, including the OP's example). What version of vim are you using?
1

Goto the second line with \} on it.
Hit Cap J
Hit escape and x out any spaces as needed.

1 Comment

Capital J J-ions the two lines together.
1

And another way, because that's Vim we are talking about:

:j! 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.