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?

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 ~
        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, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.