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] Reflow selected text like Vim’s gq and gw #219

Open
multinormal opened this issue Apr 16, 2021 · 3 comments
Open

[Feature Request] Reflow selected text like Vim’s gq and gw #219

multinormal opened this issue Apr 16, 2021 · 3 comments

Comments

@multinormal
Copy link

When writing long comments, or prose in LaTeX or Markdown etc., it is often necessary to reflow/rewrap text to ensure no lines are longer than the line width, while also ensuring commented code remains correctly commented (eg if # characters begin a comment, then all lines in the reflowed comment block should start with that character, and such characters that began lines should not end up midway through the reflowed text). Doing this manually is tedious and potentially error-prone. Reflowing text can be done with Vim’s gq and gw commands, for example. It would be great to have this feature in Amp.

Example:

# This is a comment that is too long and should be reflowed.

Could be reflowed as:

# This is a comment that is
# too long and should be
# reflowed.
@oldaccountdeadname
Copy link
Contributor

I forked this very recently to add 'reflowing' (I called it justification). I've begun to implement just the simple greedy algorithm in a new selection::justify command. I still at the very least need to add tests and make sure it actually works (it probably doesn't), but it's there.

@jmacdonald
Copy link
Owner

@multinormal I wasn't aware Vim had a solution to this; I've been doing this manually (albeit only with multi-line git commit comments) for years. 😅

@LincolnAuster happy to review your PR once it's in a good place. Building that as a command feels like the right first step!

@bmaxa
Copy link

bmaxa commented May 16, 2021

It would be nice to reformat with ">" quotes like gq} in vim for usenet/mail posts. Then I can replace vim for mails usenet posts, with amp ;)

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

4 participants