1

Imagine I have comments

// line one
// line two

and I am on line one and want to join it with line two I will press J but that results in this:

// line one // line two

Instead of what I want

// line one line two

can I change the behaviour of J so that it works like this for comments?

1 Answer 1

2
set fo+=j

:h fo-table:

...
j   Where it makes sense, remove a comment leader when joining lines.  For
    example, joining:
        int i;   // the index ~
                 // in the list ~
    Becomes:
        int i;   // the index in the list ~
...
  • default formatoptions in vim8 : tcq
  • default formatoptions in neovim : tcqj

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.