Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrap comments like Vim's gq command in VS Code

For some projects I use Visual Studio Code. One thing that is bugging me is that I can't quickly format comment blocks like Vim's gq command.

For those who don't know Vim, the gq command works where you select/highlight a line or lines like this one:

// This is a really really long line right here

And it makes it like this

// this is a really
// really long line
// right here

Based on your ruler settings (mine is 80 so it would wrap on any words that go past 80.

like image 733
Oscar Godson Avatar asked Aug 05 '26 22:08

Oscar Godson


2 Answers

This extension should work for you:

https://marketplace.visualstudio.com/items?itemName=stkb.rewrap

like image 187
Bill_Stewart Avatar answered Aug 09 '26 11:08

Bill_Stewart


It has been supported by VSCodeVim.

See https://github.com/VSCodeVim/Vim#-vscodevim-tricks for details.

You can also set the width to word-wrap when using gq by vim.textwidth. It can be found at https://github.com/VSCodeVim/Vim#vim-settings.

like image 41
xxgj Avatar answered Aug 09 '26 10:08

xxgj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!