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

feature request: auto-fill-mode #45

Closed
dmose opened this issue Aug 10, 2017 · 15 comments
Closed

feature request: auto-fill-mode #45

dmose opened this issue Aug 10, 2017 · 15 comments

Comments

@dmose
Copy link

dmose commented Aug 10, 2017

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.

@stkb
Copy link
Owner

stkb commented Aug 10, 2017

Hi and thanks for the feedback and request!

I've seen this mentioned elsewhere so have thought about it a little; have just been waiting for someone to request it.

It's got some tricky aspects and might not be battery friendly. But I will look into it after the next release.

@dmose
Copy link
Author

dmose commented Aug 10, 2017

Wonderful; thanks! And I can totally see how there would be nuance to implementing this.

@giggio
Copy link

giggio commented Oct 2, 2017

I would also love to have this feature. We should be able to turn it on or off. It should be off by default.

@stkb
Copy link
Owner

stkb commented Oct 7, 2017

@giggio Agreed: there'll be a command to toggle it. I am working on this and #46 at the moment.

@calrsom
Copy link

calrsom commented Nov 1, 2017

Would love to see this for markdown, comments, and other documentation/non-code blocks!

@stkb
Copy link
Owner

stkb commented Nov 24, 2017

I now have a beta version with this feature, to try out.

The feature works similarly to that in emacs, in that it only triggers after pressing space or enter if the cursor is past the wrapping column, and it only wraps that current line (which is fine for most normal typing). If you insert text into a line of make other complex changes, you'll need to do a manual alt+q to fix everything up.

Enable it with the Rewrap: Toggle Auto-Wrap command. It will show a brief message in the status bar.

The command doesn't have a default keybinding, but you can add your own in the normal way by binding to the command rewrap.toggleAutoWrap.

Naturally it only applies in comments or markdown/text documents, so you may be fine with leaving it on all the time. You'll need to enable it each time you start vscode though, but I might change that so the on/off setting persists between sessions.

Installation

Download this .zip file and rename it to a .vsix file: rewrap-1.6.0-beta2.zip

From the extensions sidebar in vscode:

  1. Please uninstall the existing version of Rewrap first, to prevent conflicts.
  2. From the "..." menu in the top right, choose "Install from VSIX.."
  3. It should install v1.6.0-beta2 (restart needed)
  4. If/when you go back to the marketplace version, again uninstall the beta version first.

I've also changed some of the general parsing code since the last version, so you may experience other bugs.

@gwf
Copy link

gwf commented Nov 26, 2017

I just tried the beta and quickly hit an error which I filed as a new issue. LMK if you prefer that I add future problems with the beta in this thread or as separate issues.

@stkb
Copy link
Owner

stkb commented Nov 27, 2017

@gwf Thanks I've found the cause and will have a fix out soon. The problem seems to be restricted to LaTeX files.

It doesn't really matter but we can probably keep all issues with the beta here.

@stkb
Copy link
Owner

stkb commented Nov 27, 2017

Ok, here's beta 2 (have updated the comment above too)
rewrap-1.6.0-beta2.zip

As before, rename to .vsix and remove any existing version first.

Thanks for testing :)

@gwf
Copy link

gwf commented Nov 28, 2017

Looking good. All of the problems from before are resolve. Well done!

May I also suggest that you trigger auto-wrap on a space keystroke within the interior of a paragraph as well? Obviously, you only need to trigger it when the right edge is to the right of the limit. With this change, I think it will more closely approximate Emacs auto-fill-mode.

@stkb
Copy link
Owner

stkb commented Nov 28, 2017

Thanks, glad the bugs are fixed.

Do you have a plugin that does that that? Because afaik Emacs doesn't wrap when pressing space in the middle of a line (https://www.gnu.org/software/emacs/manual/html_node/emacs/Auto-Fill.html)

Auto Fill mode does not refill entire paragraphs; it breaks lines but does not merge lines. Therefore, editing in the middle of a paragraph can result in a paragraph that is not correctly filled. To fill it, call the explicit fill commands (see Fill Commands).

That's how it's working for me in both vanilla Emacs and with the AUCTeX plugin; it only wraps once the cursor is past the wrapping column again.
emacs-auto-wrap

The other way can be done, it just means having to re-adjust the whole contents of the paragraph each time, otherwise you have very undesirable results.

I could add the option for either I guess.

@gwf
Copy link

gwf commented Nov 30, 2017

@stkb, you're correct and my memory of how auto-fill-mode works in Emacs was wrong. Sorry about that.

@fxn
Copy link

fxn commented Dec 7, 2017

Vim also supports this with set fo+=a, and it is how I set things up to write text documents like my journal.

@stkb
Copy link
Owner

stkb commented Jan 14, 2018

v1.6.0 is finally published. If you're using a beta version please uninstall (& restart) before re-installing from the marketplace.

@stkb
Copy link
Owner

stkb commented Jan 15, 2018

@fxn Thanks for the tip!

Closing this one now. Have created #65 for that enhancement.

@stkb stkb closed this as completed Jan 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants