btrekkie / wrapasyoutype Goto Github PK
View Code? Open in Web Editor NEWSublime Text plugin that performs hard word wrapping within specified sections, in real time as the user types
License: MIT License
Sublime Text plugin that performs hard word wrapping within specified sections, in real time as the user types
License: MIT License
Altering text which is written back to a View
does not require special line ending handling.
The result of adding \r\n
to a view is displayed here:
A python plugin can safely use \n
to add a line break on all OSs without respect of ST's line endings setting. This setting is used by ST to decide which line ending to write to the file while saving.
Hence the _line_break()
method can be simplified:
Line 602 in 8ada426
For unclear reasons, this suddenly stopped working with JSDoc comments (i.e. wrapping doesn't happen):
{
"line_start": " * ",
"selector": "comment.block - punctuation.definition.comment"
},
With regular block comments (started with /*
, not /**
), it continues to work.
I tried to play around and figured out that removing .definition
helps. But I have no idea why and what the effect of .definition
is supposed to be (reading the manual didn't help), hence whether the removal will break the workings of the plugin in any other place.
When starting a new line within a comment block, it would be awesome if this plugin had a flag to automatically begin the new line with the line_start
character and the current indentation. This would make it much nicer to break up larger blocks of text into paragraphs.
E.g. if the cursor was here (with the pipe representing the text cursor):
# This is a test.|
And Enter is pressed twice, it should become:
# This is a test.
#
# |
Or, if the cursor is in the middle of a line:
# This is also a test. |Please do not be alarmed.
and Enter is pressed twice, it should result in:
# This is also a test.
#
# |Please do not be alarmed.
While this behavior makes sense, it's a bit unexpected. Moving a comment via Swap Lines (default key binding: ctrl+shift+up/down on Linux) into or adjacent to another comment automatically merges the two lines.
At the moment, WrapAsYouType does not handle non-breaking spaces (unicode codepoint 0xA0) very well.
First it will gladly cut a line at their position, even though by the very definition of non-breaking spaces it should refrain from doing so and cut at the previous word boundary instead.
Second, in the process of cutting a line at this incorrect position, it will replace the non-breaking space with a line feed, which means that if the things before and after the non-breaking spaces are subsequently reflowed together through more additions and deletions, the non-breaking space will effectively have been replaced with a regular space.
To be honest, I'm not sure if this is a problem in the WrapAsYouType plugin or the core Sublime engine, as I've seen other text reflow Sublime plugins handle non-breaking spaces in similarly incorrect ways.
I really like the ability to use hard wrapping only in comment sections. However, most of the time I use formatted text for documentations and not flowing text. Therefore, I would really like to see an option to enable only forward-looking word wrapping in comments. Is this possible?
Hi btrekkie!
I love this package, it's super helpful!! I did notice that the Javascript settings that were recommended in the README didn't seem to work for me (I'm using Sublime Text 3). This is what worked for me:
"wrap_as_you_type_sections": [
{
"line_start": "*", // I removed the spaces around the asterisk
"selector": "comment.block - punctuation.definition.comment"
},
{
"combining_selector":
"source - (comment | constant | entity | invalid | keyword | punctuation | storage | string | variable)",
"line_start": "\/\/", // I escaped the forward slashes
"selector": "comment.line"
}
],
}
It might be helpful to other users to call out this fix, if you confirm it?
In any case, many thanks for making this excellent package! Game changing!
-natlefiyr
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.