Vim: Consume line comment with `J`

Created on 3 Mar 2017  路  6Comments  路  Source: VSCodeVim/Vim

Please thumbs-up 馃憤 this issue if it personally affects you! You can do this by clicking on the emoji-face on the top right of this post. Issues with more thumbs-up will be prioritized.


What did you do?

// |This
//     is a comment

Press J

What did you expect to happen?

// This| is a comment

What happened instead?

// This| //     is a comment

Technical details:

  • VSCode Version: 1.10.1
  • VsCodeVim Version: 0.5.3
  • OS: OSX Sierra
kinfeature

Most helpful comment

Does this require a special setting in Vim? I can't reproduce it in Vim.

(P.S. You should use gq for this. 馃槃 )

All 6 comments

Does this require a special setting in Vim? I can't reproduce it in Vim.

(P.S. You should use gq for this. 馃槃 )

Ah, yeah I forgot it's not default. Feature added in 2012. You need to add j to formatoptions. It's very useful though.

http://ftp.vim.org/vim/patches/7.3/7.3.541

(P.S. You should use gq for this. 馃槃 )

I didn't know about this... How do I use it?

Visually select all the lines that you want to reflow and press gq. They will be reflowed into properly wordwrapped sections that preserve commenting scheme. It's really an amazing feature. 馃榿

Oh man that is sweet. How did I not know about this?!

I know right?? It's Vim's best hidden feature!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaredly picture jaredly  路  3Comments

typeoneerror picture typeoneerror  路  3Comments

ghost picture ghost  路  3Comments

st-schneider picture st-schneider  路  3Comments

lucastheisen picture lucastheisen  路  3Comments