Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command to re-wrap code to respect a preferred line length column (e.g. 80 columns) #9514

Closed
dilijev opened this issue Jul 20, 2016 · 10 comments
Labels
*extension-candidate Issue identified as good extension implementation feature-request Request for new features or functionality
Milestone

Comments

@dilijev
Copy link

dilijev commented Jul 20, 2016

  • VSCode Version: Code - Insiders 1.4.0-insider (f4780e6, 2016-07-19T05:07:05.876Z)
  • OS Version: Windows_NT ia32 10.0.14390

For example, in Vim, you can select multiple lines of text and type gq and lines will be re-wrapped so that they don't exceed the setting for max line length (e.g. 80 columns).

It would be nice to see a similar feature in VS Code especially for wrapping comments, which also has the behavior of correctly inserting a syntax-aware single-line comment token (e.g. //) at the beginning of each wrapped line (and not moving that token into the re-wrapped text of the same lines).

Would also like this functionality to respect the indentation level of the code.

@kieferrm kieferrm added the feature-request Request for new features or functionality label Jul 20, 2016
@aeschli aeschli added this to the Backlog milestone Jul 21, 2016
@aeschli aeschli changed the title [Request] Command to re-wrap code to respect a preferred line length column (e.g. 80 columns) Command to re-wrap code to respect a preferred line length column (e.g. 80 columns) Jul 21, 2016
@aeschli aeschli removed their assignment Jul 21, 2016
@stkb
Copy link
Contributor

stkb commented Aug 3, 2016

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

@dilijev
Copy link
Author

dilijev commented Aug 3, 2016

@stkb Thanks. What is the distinction between features that should be added as a part of VS Code by default versus things which should be added as extensions?

@stkb
Copy link
Contributor

stkb commented Aug 4, 2016

To paraphrase something @bpasero once said: if it can be done as an extension, it should be done as an extension. Of course, some (small) features that were once extensions do get added to vscode from time to time.

@lorenzodallavecchia
Copy link

For languages that have a formatter (above all, TypeScript), the wrapping behavior would also make sense as part of the formatter.
The maximum line length for code and comments could be configured as two new formatter options, and the language service may make smart decisions about where to break the lines to not hurt readability.

Are there any plans for such a feature?

@alexburner
Copy link

+1 for having max line length as part of the formatter. I'm on a hunt for a prettier alternative, it just hit 1.0 but doesn't support TypeScript (prettier/prettier#13)

Ideally my team would like a formatter (for ts/tsx) that handles an 80 col limit with the proper line breaks/indentation to make it look good. I'm looking at typescript-formatter (https://github.com/vvakame/typescript-formatter), which seems to be powered by tsc (https://github.com/vvakame/typescript-formatter/blob/master/lib/formatter.ts#L4), but also used by the VS Code team? (#17627)

@evmar
Copy link

evmar commented Apr 18, 2017

clang-format (http://probst.io/blog/2015/01/15/clang-format-for-javascript/) supports TypeScript and does intelligent wrapping.

@alexburner
Copy link

Thank you @evmar ! I will look into this

@cyda89
Copy link

cyda89 commented Nov 12, 2017

+1 for having max line length as part of the formatter. Since it is included for html ("html.format.wrapLineLength"), why should it not be for js/ts etc.?

@alexburner
Copy link

alexburner commented Nov 12, 2017

FWIW, prettier now supports typescript, and handles max line length:
https://prettier.io/docs/en/language-support.html
https://prettier.io/docs/en/options.html#print-width

@mjbvz mjbvz added the *extension-candidate Issue identified as good extension implementation label May 17, 2018
@vscodebot
Copy link

vscodebot bot commented May 17, 2018

We try to keep VS Code lean and we think the functionality you're asking for is great for a VS Code extension. Maybe you can already find one that suits you in the VS Code Marketplace. Just in case, in a few simple steps you can get started writing your own extension. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot closed this as completed May 17, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jul 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*extension-candidate Issue identified as good extension implementation feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

9 participants