GithubHelp home page GithubHelp logo

stkb / rewrap Goto Github PK

View Code? Open in Web Editor NEW
487.0 4.0 58.0 3.34 MB

Rewrap extension for VSCode and Visual Studio

Home Page: https://marketplace.visualstudio.com/items/stkb.rewrap

License: Other

JavaScript 6.70% C# 16.92% F# 67.08% TypeScript 9.27% Shell 0.02% Batchfile 0.01%

rewrap's Introduction

For VS Code, Open VSX and Visual Studio.
Latest stable version 1.16.3 / pre-release 17.x / changelog

Rewrap



The main Rewrap command is: Rewrap Comment / Text, by default bound to Alt+Q. With the cursor in a comment block, hit this to re-wrap the contents to the specified wrapping column.

Features

  • Re-wrap comment blocks in many languages, with per-language settings.
  • Smart handling of contents, including Java-/JS-/XMLDoc tags and code examples.
  • Can select lines to wrap or multiple comments/paragraphs at once (even the whole document).
  • Also works with Markdown documents, LaTeX or any kind of plain text file.

The contents of comments are usually parsed as markdown, so you can use lists, code samples (which are untouched) etc:

rewrap's People

Contributors

acmiyaguchi avatar adrn avatar alanag13 avatar bbugh avatar bradleyayers avatar carlreinke avatar dependabot[bot] avatar erikswan avatar jeremywiebe avatar jyasskin avatar lgo avatar mk12 avatar sighery avatar stkb avatar tfiers avatar wilstead avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rewrap's Issues

Wrapping behavior broken in vscode 1.1.0

This:

This is a quick test of rewrap after upgrading vscode to v1.1.0.
This used to work great in 1.0.0, but now, things get really weird after
triggering the rewrap plugin.

Turns into this:

This is a quick test of rewrap
after upgrading vscode to v1.1.0.
This used to work great in 1.0.0,
but now, things get really weird
after triggering the rewrap
plugin.triggering the rewrap plugin.

Note that this happens even if I set the rewrap.wrappingColumn setting to 80. There's no trailing whitespace anywhere.

Behavior of undo

If you rewrap an existing comment, then you can use undo to undo the rewrapping.

However if you type some text and then rewrap immediately after, undo will undo the rewrapping but also remove the text. Need to investigate further (this may be a bug in vscode).

\0 replaced with <space> during rewrap

Rewrap 1.5.0. Put this in a text file:

foo\0bar\0baz

After Alt-Q:

foo bar baz

Just to be clear, I'm not talking about actual embedded NUL bytes, I mean instances of the literal string "\0" (backslash zero) are being replaced with what appear to be space characters.

Very strange!

Updated rewrap, and now it's wrapping one particular comment at the wrong column

Here's the improper result (stripped down to the smallest repro):

package main

const (
    // PayoutStatusStarted represents the value of a
    // payout row's `status` column. It represents a
    // payout that has been validated and started but has
    // not yet been completed.
    PayoutStatusStarted = "started"

    PayoutStatusSuccess = "success"
)

Expected:

package main

const (
    // PayoutStatusStarted represents the value of a payout row's `status` column.
    // It represents a payout that has been validated and started but has not yet
    // been completed.
    PayoutStatusStarted = "started"

    PayoutStatusSuccess = "success"
)

Now, here's the really weird part: If the file is not saved to disk, rewrap works properly... I can create a new empty file, set the syntax to "Go", paste that code and rewrap the comment and it properly wraps to 80 columns. If I then simply save that file to the disk, rewrap starts improperly wrapping the comment to ~55 columns.

Multiline comment; cursor on last line.

/* Some
text
*/|

If the last line has no text, the comment doesn't get wrapped if initiated when the cursor is anywhere on the last line. Minor but it should be fixed, without breaking anything else.

Wrapping column setting not sticking in VS version

The current Visual Studio version has a bug where if you change the wrapping column in the settings and then hit OK, the change won't be persisted.

Will be fixed in the next version but as a workaround, you have to switch focus from the textbox to another control first before clicking OK.

Does not insert single-line comment tokens when wrapping a comment.

  • Re-wrap 0.5.3
  • VSCode Version: Code - Insiders 1.4.0-insider (e3758d2cdaae78082a08a45ae28ea1bed5f47e8c, 2016-07-29T18:41:58.915Z)
  • Windows 10 Build 14393.10

Repro Steps:

Begin with (on a single line):

// Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc.

Ctrl+K Ctrl+W

End result:

// Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor
congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus
malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet
enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique
senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy
pede. Mauris et orci. Aenean nec lorem. In porttitor. Donec laoreet nonummy
augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis,
nunc.

Expected result should be like:

// Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor
// congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus
// malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet
// enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique
// senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy
// pede. Mauris et orci. Aenean nec lorem. In porttitor. Donec laoreet nonummy
// augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis,
// nunc.

Additionally, when re-wrapping multiple lines of comments beginning with a single-line comment token, the tokens should be removed before re-wrapping and re-inserted after wrapping so that stray (useless) comment tokens don't end up in the middle of a line.

Shortcut conflict

The shortcut for rewrapping comments conflicts with VSCode's default View: Close All Editors command shortcut.

Since there is already an alternative (Alt+Q), can this be removed?

* at the start of each line not really working

Reformatting comments such as this doesn't work. It needs to identify that every line begins with a start and insert one at the start of the line when wrapping etc.

	/**
	 * Returns the number of samples that can be read, and a pointer where you 
	 * can start reading the samples.  Two calls may be necessary as the samples
	 * to be read might wrap around in memory.
	 * 
	 * This call doesn't copy the samples to a new buffer so is more efficent for
	 * some tasks, e.g. metering, where you just want to calculate a value from 
	 * the available data.  
	*
	* @returns the number of samples, per channel.
	 */

Option to use absolute column width

Thanks for this plugin! However, I find that I want columns to wrap at (for example) column 76, not be 76 characters wide no matter where they start. This means that comments that start at an indent will need to be wrapped narrower to keep below the max column width, but that's fine.

To illustrate with an extreme example, given rewrap.wrappingColumn: 22 it current does

// wrapped at column
// twenty-two.

    // wrapped at column
    // twenty-two.

with the second paragraph exceeding column 22, while I would prefer

// wrapped at column
// twenty-two.

    // wrapped at
    // column
    // twenty-two.

Could there be an option to take the indent into account to accomplish this?

Doesn't work that good with Cyrillic text

The Problem

Consider this sample:

First paragraph is written in Latin alphabet:

qqqqqqqqqqqqq qqqqqqqqqq qqqqqqqqqqqqq qqqqqqqqqq qqqqqqqqqqqqq qqqqqqqqqq qqqqqqqqqqqqq qqqqqqqqqq qqqqqqqqqqqqq qqqqqqqqqq

Second paragraph is written with Cyrillic `я`:

яяяяяяяяяяяяя яяяяяяяяяя яяяяяяяяяяяяя яяяяяяяяяя яяяяяяяяяяяяя яяяяяяяяяя яяяяяяяяяяяяя яяяяяяяяяя яяяяяяяяяяяяя яяяяяяяяяя

After I select both paragraphs and press Alt + Q (hotkey for "Rewrap Comment / Text" action in my VSCode), the first paragraph gets rewrapped, but the second isn't:

First paragraph is written in Latin alphabet:

qqqqqqqqqqqqq qqqqqqqqqq qqqqqqqqqqqqq qqqqqqqqqq qqqqqqqqqqqqq qqqqqqqqqq
qqqqqqqqqqqqq qqqqqqqqqq qqqqqqqqqqqqq qqqqqqqqqq

Second paragraph is written with Cyrillic `я`:

яяяяяяяяяяяяя яяяяяяяяяя яяяяяяяяяяяяя яяяяяяяяяя яяяяяяяяяяяяя яяяяяяяяяя яяяяяяяяяяяяя яяяяяяяяяя яяяяяяяяяяяяя яяяяяяяяяя

Sometimes the Cyrillic text can be rewrapped if it contains some words in Latin, but most of the time it doesn't work.

Possible Reason

Please note that the common issue with this kind of trouble is JS regex engine: its' \w doesn't work with all different scripts (Cyrillic and others). Take a look on how I've solved a similar problem in another project (the fix was very simple, but requires additional module from npm): maptz/Maptz.VSCode.Extensions.CamelCaseNavigation#8

Wrapping string literals in Java

With https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack + Rewrap installed, following code:

  private void checkState() {
    if (job == null) {
      throw new IllegalStateException("Job was not initialized, deploy() has to be invoked or failed the invocation");
    }
  }

Gets rewrapped to following:

  private void checkState() {
    if (job == null) {
      throw new IllegalStateException("Job was not initialized, deploy() has to
      be invoked or failed the invocation");
    }
  }

LaTeX: preserve newlines for enumerations

First off, thanks for this awesome plugin! It is exactly what I've been looking for for a while.

I just began using Rewrap to edit LaTex. It works great for almost all cases, but I noticed one issue. When wrapping enumerations, Rewrap will try to wrap multiple items into the same row. For instance, it will make the transformation from:

\begin{enumerate}
    \item $\neg aRa$ (irreflexive)
    \item $aRb ^ bRa \Rightarrow a = b$ (antisymmetric)
    \item $aRb ^ bRc \Rightarrow aRc$ (transitive)
\end{enumerate}

to

\begin{enumerate}
    \item $\neg aRa$ (irreflexive) \item $aRb ^ bRa \Rightarrow a = b$ (antisymmetric) \item $aRb ^
    bRc \Rightarrow aRc$ (transitive)
\end{enumerate}

I'd expect the plugin to respect the newlines for each item. I saw that you recently added LaTeX support in v1.1.0, so this is probably a result of how new the support is.

Not working on properly on some types of files

Eg shell script, VB. It wraps longer lines but doesn't combine shorter lines. Other types eg javascript are working fine.

Input:

# a
# b

Expected:

# a b

Actual:

# a
# b

It's a regression going from v0.5.3 to v0.6.0

Wrapping in lua removes newlines

If I try to wrap this lua code (Select all -> alt+Q)

local function dump()
    local a = 1
    local b = 2
    local d
    d = a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + b;
end

I get

local function dump()
    local a = 1 local b = 2 local d d = a + a + a + a + a + a + a + a + a + a +
    a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a + a +
    a + a + a + a + a + b
end

Though this is still valid lua code but not the expected output.

Bug when rewraping markdown quotes

If you have a quote, e.g.:

> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae cursus risus.
Vivamus pharetra venenatis dapibus. Aenean non nisi tempus, consectetur augue
vitae, venenatis augue. Etiam quis euismod felis, vitae ultricies orci. Nam
mollis, nunc vel faucibus rhoncus, lacus leo porta quam, quis molestie magna
massa ut ex. Ut sed pulvinar massa, vel egestas orci. Phasellus tempor justo
quam, vel luctus urna tempus ac. Donec id ante ipsum. Ut placerat feugiat dui,
sit amet posuere velit tincidunt nec. Curabitur aliquam gravida ante in
suscipit.

using the Rewrap command copies the second line to each word in the quote after this line.

f.e.:

> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae cursus risus.
Vivamus pharetra venenatis dapibus. Aenean non nisi tempus, consectetur augueVivamus
Vivamus pharetra venenatis dapibus. Aenean non nisi tempus, consectetur auguepharetra
Vivamus pharetra venenatis dapibus. Aenean non nisi tempus, consectetur auguevenenatis
Vivamus pharetra venenatis dapibus. Aenean non nisi tempus, consectetur auguedapibus.
...

Keep double asterisks on opening line

When reformatting a parsable block comment (phpdoc in my case), the second asterisk on the opening line is removed, effectively downgrading it to a regular comment.

Default keybinding

I might have messed up here when choosing the ctrl+k ctrl+w keybinding. I was trying to choose one that was in-keeping with other vscode bindings but not already used. As it turns out, ctrl+k ctrl+w is already used (though not for a super-important action: workbench.files.action.closeAllFiles).

The shortcuts for this function in Sublime, Emacs, Vim all involve the letter Q.

It's not a huge deal as anyone can remap it to any binding they like, but if most people are doing that then maybe there's a better default to be had.

  • Copying Sublime's Alt+Q might be the most sensible option but I'm not happy about a possible conflict with a menu item; if not in English, then in some other language.
  • Alt+Shift+Q fits with other "formatting"-type commands, like format document (alt+shift+f), but it's difficult to get your fingers around.
  • Ctrl+K Ctrl+Q is another option that's currently free, as is Ctrl+Shift+Q

In any case, if I did choose a different default binding, I'd definitely still keep the old one around for at least a while so as not to break it suddenly for anyone.

If anyone has any comments, please add them here.

Miswrapping on bash scripts

I have a file that I set language to Shell Script (bash). It has contents:

#!/bin/bash

# This script exists because custom-script-shim will detach the enable command
# into background and when that happens the custom-script shim will exit,
# causing test container to exit as its entrypoint has exited. So we use this
# to wait indefinitely until enable background process disappears from ps output.

when I run rewrap on this comment block I get

# This script exists because custom-script-shim will detach the enable command #
into background and when that happens the custom-script shim will exit, #
causing test container to exit as its entrypoint has exited. So we use this # to
wait indefinitely until enable background process disappears from ps output.

screenshot:
image

I use vscode version 1.3.1 and rewrap version 0.5.2

feature request: auto-fill-mode

First off, thanks for writing Rewrap; this is really great and already makes editing code a bunch easier!

An even higher level of awesome would be to support the equivalent of emacs auto-fill mode, where it fixes up wrapper automagically while you type.

Preserve indentation of the first line to wrap

It would be handy, e.g. when working with LaTeX, Markdown or mark-up languages in general, if wrapping preserved the indentation of the first line. Ideally, lines such as

    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
    \item Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

    * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
    * Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

would be magically wrapped to

    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit,
          sed do eiusmod tempor incididunt ut labore et dolore
          magna aliqua
    \item Ut enim ad minim veniam, quis nostrud exercitation
          ullamco laboris nisi ut aliquip ex ea commodo consequat.

    * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
      do eiusmod tempor incididunt ut labore et dolore magna
      aliqua
    * Ut enim ad minim veniam, quis nostrud exercitation ullamco
      laboris nisi ut aliquip ex ea commodo consequat.

However, since this is probably difficult to achieve in general, it would already be great if the indentation of the first selected line were preserved when wrapping. E.g. selecting and wrapping the second line of the block

    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit,
          sed do eiusmod tempor incididunt ut labore et dolore magna aliqua excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

would preserve the manually created indentation and yield

    \item Lorem ipsum dolor sit amet, consectetur adipiscing elit,
          sed do eiusmod tempor incididunt ut labore et dolore
          magna aliqua excepteur sint occaecat cupidatat non
          proident, sunt in culpa qui officia deserunt mollit anim id
          est laborum.

This should also work if multiple lines are selected: e.g. selecting and wrapping the second and all subsequent lines of the block

    * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
      do eiusmod tempor incididunt ut labore et dolore magna aliqua excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum, duis aute irure dolor in reprehenderit
    in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

should yield

    * Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
      do eiusmod tempor incididunt ut labore et dolore magna
      aliqua excepteur sint occaecat cupidatat non proident, sunt in
      culpa qui officia deserunt mollit anim id est laborum, duis aute
      irure dolor in reprehenderit in voluptate velit esse cillum
      dolore eu fugiat nulla pariatur.

Visual Studio equivalent to Rewrap?

Is there a Visual Studio equivalent to Rewrap? This looks great but I don't use VS Code. I would love to have this functionality in Visual Studio 2015.

Feature request: rewrap paragraph

For longer comments that include some formatting, it would be useful to have a "rewrap paragraph" command that only rewraps the current paragraph within a comment, leaving the rest of the comment as-is.

YAML support

This doesn't seem to work with multiline YAML strings.

vscode v1.7.1
vscode-rewrap v0.6.3

Feature request: support bullet lists

I use this addon a hundred times a day, and the one feature I really miss is support for bullet lists, which are pretty common in longer comments. Concretely, I'd like text like this to remain intact after wrapping:

This is a list:

    - Point one
    - Point two

It would also be a huge improvement in my quality of life if bullets themselves could be wrapped correctly. So that text like this:

A list:
   
    - Line one
    - Let's pretend this is a super long line that requires wrapping
    - Line three

Wrapped like this:

A list:
   
    - Line one
    - Let's pretend this is a super long 
      line that requires wrapping
    - Line three

Cannot read property '0' of null

Trying to rewrap any comments in a particular Go file, I get this. Just one file, others work fine. I can take comments from that file into another file and they wrap fine.

[Extension Host] TypeError: Cannot read property '0' of null
at new Section (C:\Users\user.vscode\extensions\stkb.rewrap-0.6.2\out\src\Section.js:19:66)
at BasicLanguage.findSections (C:\Users\user.vscode\extensions\stkb.rewrap-0.6.2\out\src\BasicLanguage.js:35:38)
at wrapSomething (C:\Users\user.vscode\extensions\stkb.rewrap-0.6.2\out\src\Main.js:33:28)
at C:\Users\user.vscode\extensions\stkb.rewrap-0.6.2\out\src\Main.js:15:20
at c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:12:29051
at e.edit (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:11:24633)
at c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:12:29017
at t.$executeContributedCommand (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:11:4834)
at t.e.handle (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:10:22905)
at s (c:\Program Files (x86)\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:7:30449)

Selection/cursor position after wrapping

From @natefinch at microsoft/vscode#2770 (comment)

One oddity is that it seems to leave wrapped text selected if my cursor was in the text that got wrapped, which means I end up overwriting the text if I wrap in the middle of typing.

So like, if I write "abc 123 456" and my cursor is after the 6, and the wrapping point is between the letters and numbers. When I wrap, all the text that gets moved to the next line (the numbers) will be selected (with my cursor at the end of the selection).

TOML support

When using Rewrap in *.toml files, wrapping behaves unexpectedly. These same issues do not occur with all file types; *.toml is the first I've come across that does this.

Lines beginning with +, -, * or @ for example, will ignore any preceding lines and only perform the wrap on the line itself and any that follow contiguously. There may be other symbols with the same behaviour.

Lorem ipsum dolor sit amet,
@consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua.

A line that specifically begins with a # and is followed by white space will not wrap at all.

Lorem ipsum dolor sit amet,
# consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua.

Thanks.

Powershell CBH indentation issue

Hi,
If i wrap an entire powershell script containing the comment-based-help section, all LF are removed.

Example

Input

<#
.SYNOPSIS
  Return a configuration object from a yml file.
.DESCRIPTION
  Get all configuration settings from a yml file, rewrite relative path to absolute path, return an
  hashtable object.
.PARAMETER YamlPath
  Optional - Path of the yaml configuration file.
.EXAMPLE
  $config = .\GetConfig
  $config is filled by configuration settings from ProjectRoot\config\project.yml file.
.EXAMPLE
  $config = .\GetConfig .\myConfig.yml
  $config is filled by configuration settings from .\myConfig.yml file.
.INPUTS
  None.
.OUTPUTS
  Hashtable object containing all configuration settings.
#>

Output (after Rewrap action)

<#
.SYNOPSIS Return a configuration object from a yml file. .DESCRIPTION Get all configuration settings
  from a yml file, rewrite relative path to absolute path, return an hashtable object. .PARAMETER
  YamlPath Optional - Path of the yaml configuration file. .EXAMPLE $config = .\GetConfig $config is
  filled by configuration settings from ProjectRoot\config\project.yml file. .EXAMPLE $config =
  .\GetConfig .\myConfig.yml $config is filled by configuration settings from .\myConfig.yml file.
  .INPUTS None. .OUTPUTS Hashtable object containing all configuration settings.
#>

Expected output

<#
.SYNOPSIS
  Return a configuration object from a yml file.
.DESCRIPTION
  Get all configuration settings from a yml file,
  rewrite relative path to absolute path, return
  an hashtable object.
.PARAMETER YamlPath
  Optional - Path of the yaml configuration file.
.EXAMPLE
  $config = .\GetConfig
  $config is filled by configuration settings from
  ProjectRoot\config\project.yml file.
.EXAMPLE
  $config = .\GetConfig .\myConfig.yml
  $config is filled by configuration settings from
  .\myConfig.yml file.
.INPUTS
  None.
.OUTPUTS
  Hashtable object containing all configuration settings.
#>

Support rewrap of text in certain HTML tags

Rewrap 1.0.0 in VSCode 1.8.0

It'd be nice to support rewrap in HTML-embedded JS/CSS.

So that this:

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <script>
        // Support rewrap of JS comments in HTML script tags Support rewrap of JS comments in HTML script tags
    </script>
</head>

<body>
</body>

</html>

becomes this:

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <script>
        // Support rewrap of JS comments in HTML script tags Support rewrap of
        // JS comments in HTML script tags
    </script>
</head>

<body>
</body>

</html>

instead of this currently:

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <script>
        // Support rewrap of JS comments in HTML script tags Support rewrap of
        JS comments in HTML script tags
    </script>
</head>

<body>
</body>

</html>

Default wrapping column to smallest ruler

rewrap.wrappingColumn defaults to 0 which seems to produce a wrap somewhere around column 81. It's easy enough to change rewrap.wrappingColumn, but I think it would be more intuitive if the default value of 0 would caused the wrapping column to be the smallest value in the editor.rulers configuration array if editor.rulers is set.

My most common use of extension is to wrap Python docstrings to 72 columns where I have my editor.rulers set to [72, 79].

Thanks for the useful extension! I greatly appreciate the effort you've already put into this, and have no expectation that you do anything about this issue. I only opened the issue in case you or anyone else was already thinking about it, and needed a +1.

Wrapping a long line which is partly commented

When a line begins with a non-comment part which is followed by a (long) comment, it is wrapped incorrectly. For instance,

                                            |
int main() // this is a long comment which starts from the middle of a line.
                                            |

becomes

                                            |
int main() // this is a long comment which  |
starts from the middle of a line.           |
                                            |

This happens, for instance, C and LaTeX. Perhaps for other formats as well.

I guess the expected result is

                                            |
int main() // this is a long comment which  |
// starts from the middle of a line.        |
                                            |

Indeed emacs does filling in this way.

Feature request: wrap to each ruler

If there are multiple rulers, vscode-rewrap wraps to the first one. It would be super useful if it would wrap to each one of them as the wrap key is pressed.

The reason I have multiple rulers is that in working with many projects/codebases/languages, there are many line lengths in use, whether due to different language style guides or even varying project conventions.

Instead of reconfiguring for each project, it would be natural to just mash the rewrap key several times, each time wrapping to one of the ruler settings, until the right one is found.

Users with only one ruler setting wouldn't see this behavior. It would only wrap to their single setting. So it would behave as it does now for those users.

Perhaps even include 'undo' in the list, so that the n+1 keypress returns the text to the unwrapped version. Faster than reaching for undo.

Indenting issue

image

Pressing rewrap on this paragraph results in this output, which looks correct:

image
Pressing rewrap again, results in this obviously incorrect example:

image

And further presses continue to increase the indent of the 2nd to 4th lines.

Cursor position after wrapping

IIRC the behavior of Alt-Q in SublimeText is to move the cursor along with the wrapped text. e.g.:

(before wrap)
foo bar baz |quux

(after wrap)
foo bar
baz |quux

I like this behavior because it allows me to continue typing where I left off. rewrap instead positions the cursor after bar, so I have to reposition.

It would be nice if the default behavior were changed, but I'd be perfectly happy with a config option as well.

New version 1.4 beta

Firstly apologies that this repo has been neglected the last couple of months and thanks for all issues and requests submitted. Apart from some other real life issues, I have been working on a new version of Rewrap.

The next version will support VSCode and Visual Studio (#36) together from the same new codebase.
Because of the large changes, I'm putting this version out as a beta first for testing.

The main change is that all comments are now parsed as Markdown*. Markdown is increasingly being used in documentation comments in various languages, and this adds support for bulleted/numbered lists (#28), as well as other features.

*(except .Net XmlDoc comments, which are parsed as xml)

But what if some parts of your comments are still getting messed up by Rewrap? (#29)

New setting: wholeComment: (true/false)

This setting affects whether the whole comment is re-wrapped, when a cursor (empty selection) is inside it. With this set to true, the whole comment is wrapped. This is how Rewrap has behaved until now.

However with wholeComment set to false, only the containing paragraph is wrapped and the rest of the comment is left untouched.

This is maybe how it should have worked from the beginning and so in the new Visual Studio extension I'm trying the default as false. However in vscode, the default will be true for consistency with previous versions, and users can set it to false if they wish.

New setting: tidyUpIndents: (true/false) [Experimental]

Turning on this experimental setting will tidy up paragraph indents when re-wrapping. For more information see here.


Like everything else, these settings are configurable on a per-language or project basis.

Other issues fixed in this version: #32, #33, #34, #37, #38

VSCode version

rewrap-1.4.0-beta1.zip

To install:

  • Download the .zip file and rename it to a .vsix file
  • In vscode, go the the extensions panel (ctrl+shift+x)
  • You must uninstall version 1.3.0 first and then restart vscode
  • Go back to the extensions panel and from the (…) menu, choose "Install .vsix file…" and choose the .vsix file

Visual Studio version

I haven't written a Visual Studio extension before and it's pretty involved, so this version is still rough around the edges, but the core functionality is the same. The main limitation at the moment, is the inability to set settings per language/document type. Also VS doesn't support multiple selections or rulers natively so I'm looking into options for that.

Versions supported are VS 2015 and 2017 (tested on community editions)

Rewrap.VS.0.1.zip

To install:

  • Download the .zip file and rename it to a .vsix file
  • Run the .vsix file

Using:

  • The entry "Rewrap Lines" is added to the Edit menu. It's bound by default to Alt+Q
  • Options are under Tools -> Options -> Environment -> Rewrap

Thanks to all

Don't wrap long URLs

Rewrap hard wraps strings at the rewrap.wrappingColumn, which can break URLs if they are longer than rewrap.wrappingColumn.

screen shot 2016-09-06 at 11 33 32 am

screen shot 2016-09-06 at 11 33 43 am

Array prototype changes causing exceptions in other extensions

Greetings!

I have been working on debugging an exception occurring in the vscode-go extension. I have traced it back to your extension altering the prototype for Array.

https://github.com/stkb/vscode-rewrap/blob/master/src/extensions.ts

Unfortunately, my knowledge of javascript is limited, so I am not sure what the appropriate solution is here. I'm opening this issue so both sides can work together to figure out an appropriate solution.

Please see microsoft/vscode-go#915.

Thanks!

Sentence ending

In the Vim gq operator and the Emacs fill-paragraph command, when we have something like,

A long sentence on a line, longer than the width, ending on the line with a period.
Another sentence on the next line.

it will be refilled into something like

A long sentence on a line, longer than the width, ending on the line with 
a period.  Another sentence on the next line.

with two spaces after the period. This is also the convention recommended by some coding standards like PEP8. vscode-rewrap has awesome features. If an option can be added for the handling of sentence ending, it could be really great!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.