Unwrap Text (Preserve Paragraphs) ― an extension for Visual Studio Code
-
On various occasions I sought, but failed to find, an extension that:
- unwraps text (removes line endings) and
- preserves blank (empty) lines between paragraphs.
After another fruitless search today, …
Result:
I tested the extension with a selection of text that comprised three paragraphs. Success.
-
G grahamperrin@mastodon.bsd.cafe shared this topic
G grahamperrin@mastodon.social shared this topic -
On various occasions I sought, but failed to find, an extension that:
- unwraps text (removes line endings) and
- preserves blank (empty) lines between paragraphs.
After another fruitless search today, …
Result:
I tested the extension with a selection of text that comprised three paragraphs. Success.
Step 0: check your document does not contain the word "aardvark"
Step 1: replace 2 [newline]s in a row with "aardvark"
Step 2: replace [newline] with [space]
Step 3: replace [two spaces] with [1 space]
Repeat step 3 until no matches are found.
Step 4: replace "aarvark" with 2 [newline]s
End.
-
On various occasions I sought, but failed to find, an extension that:
- unwraps text (removes line endings) and
- preserves blank (empty) lines between paragraphs.
After another fruitless search today, …
Result:
I tested the extension with a selection of text that comprised three paragraphs. Success.
-
Step 0: check your document does not contain the word "aardvark"
Step 1: replace 2 [newline]s in a row with "aardvark"
Step 2: replace [newline] with [space]
Step 3: replace [two spaces] with [1 space]
Repeat step 3 until no matches are found.
Step 4: replace "aarvark" with 2 [newline]s
End.
@lproven@social.vivaldi.net said:
End.
Additional background, for readers who might not read the chat.
- Numerous fruitless searches over a period of many months
- today I used Zotero on Kubuntu to make an addition to the FreeBSD collection in my shared library
- for an abstract, I copied three paragraphs from Firefox, the result was messy
- in VSCode, for the umpteenth time, I was frustrated by the inability to get what I want with a single step
- more searches
- I experimented with an extension that lacked the required feature – IIRC its description was misleading
- I uninstalled the extension
- more searches
- I experimented with a different extension that did only part of what I want
- more searches
- thanks to Claude, which created what neither I nor Claude could find in the marketplace, I gained what was required
- I used the new extension in VSCode
- the result (the abstract in Zotero) is not messy
- I'm no longer frustrated.
The end? Hopefully not.
Someone else might benefit, might be less frustrated, as a result of the streamlining.
A single step (using the new extension), instead of multiple steps.
-
@gumnos@mastodon.bsd.cafe said:
… fmt(1) or par(1)
I have only one of those:
grahamperrin@mowa219-gjp4 ~> man fmt grahamperrin@mowa219-gjp4 ~> man par No manual entry for par grahamperrin@mowa219-gjp4 ~ [16]> par Command 'par' not found, but can be installed with: sudo apt install par grahamperrin@mowa219-gjp4 ~ [127]>Ubuntu Manpage: fmt - Reformat paragraphs from input (or standard input) to stdout.
– that's too complicated for me.
… Vim's …
I was a vocal hater of vi(1) before I switched from FreeBSD to Kubuntu.
Ubuntu includes nano, which was my preferred text editor on FreeBSD (editors/nano is GPLv3, so we can't expect the Project to include it with the base system).
Frustration with
viis not an isolated incident:I ran
vimfor the first time in Kubuntu, then escaped. Naturally, my first run will be my last
-
@gumnos@mastodon.bsd.cafe said:
… fmt(1) or par(1)
I have only one of those:
grahamperrin@mowa219-gjp4 ~> man fmt grahamperrin@mowa219-gjp4 ~> man par No manual entry for par grahamperrin@mowa219-gjp4 ~ [16]> par Command 'par' not found, but can be installed with: sudo apt install par grahamperrin@mowa219-gjp4 ~ [127]>Ubuntu Manpage: fmt - Reformat paragraphs from input (or standard input) to stdout.
– that's too complicated for me.
… Vim's …
I was a vocal hater of vi(1) before I switched from FreeBSD to Kubuntu.
Ubuntu includes nano, which was my preferred text editor on FreeBSD (editors/nano is GPLv3, so we can't expect the Project to include it with the base system).
Frustration with
viis not an isolated incident:I ran
vimfor the first time in Kubuntu, then escaped. Naturally, my first run will be my last
> I only have one of those
Yeah, IIRC fmt(1) tends to be more broadly available while par(1) takes some of those ideas and makes them more powerful¹ (handling quoted email text, adjusting/not-adjusting spacing after periods, and a bunch of other knobs you can twiddle) at the cost of complex options.
I just set my $PARINIT env variable (snagged from around the web to handle inter-sentence-spacing the way I want) and invoke it as "par" without needing to provide additional details.
And both work fine from any $EDITOR that allows for passing a region of text through an external process. It looks like nano has an "execute" command² that, if the first character is a pipe, will replace the buffer/region with the results, so not just vi/vim or emacs.
⸻
¹ https://manpages.org/par
² https://www.nano-editor.org/dist/latest/nano.html bound to ^T by default -
My favourite editor last century was TextWrangler, which became BBEdit.
BBEdit's Text Handling Features | Bare Bones Software
Then, I abandoned Mac OS X, and I never found an comparable editor that did what I wanted out of the box (or with an extension).
Now, eleven years later, I'm happy.
-
@lproven@social.vivaldi.net said:
End.
Additional background, for readers who might not read the chat.
- Numerous fruitless searches over a period of many months
- today I used Zotero on Kubuntu to make an addition to the FreeBSD collection in my shared library
- for an abstract, I copied three paragraphs from Firefox, the result was messy
- in VSCode, for the umpteenth time, I was frustrated by the inability to get what I want with a single step
- more searches
- I experimented with an extension that lacked the required feature – IIRC its description was misleading
- I uninstalled the extension
- more searches
- I experimented with a different extension that did only part of what I want
- more searches
- thanks to Claude, which created what neither I nor Claude could find in the marketplace, I gained what was required
- I used the new extension in VSCode
- the result (the abstract in Zotero) is not messy
- I'm no longer frustrated.
The end? Hopefully not.
Someone else might benefit, might be less frustrated, as a result of the streamlining.
A single step (using the new extension), instead of multiple steps.
Honestly I never knew this was something so hard that anyone wouldn't be able to just... work it out. Sorry.
There are import tools in a number of word processors that can do things like it. I don't know what you searched for, or how you searched, but I'd think this was a very FA sort of Q.
The FOSS fundies will not like me saying this, but I find MS Word one of the very best tools for search-and-replace operations like this.
It has magic character combinations. The only ones I usually use, I memorised decades ago:
^p = newline
^t = tab
Space is just a space... so to remove extra spaces, in the "Search for" box, enter 2 spaces, and in the "Replace with" box, one. Then hit "Replace all", and repeat until it says there were no matches. -
Honestly I never knew this was something so hard that anyone wouldn't be able to just... work it out. Sorry.
There are import tools in a number of word processors that can do things like it. I don't know what you searched for, or how you searched, but I'd think this was a very FA sort of Q.
The FOSS fundies will not like me saying this, but I find MS Word one of the very best tools for search-and-replace operations like this.
It has magic character combinations. The only ones I usually use, I memorised decades ago:
^p = newline
^t = tab
Space is just a space... so to remove extra spaces, in the "Search for" box, enter 2 spaces, and in the "Replace with" box, one. Then hit "Replace all", and repeat until it says there were no matches.grahamperrin said:
A single step … instead of multiple steps.
@lproven@social.vivaldi.net said:
… and repeat until …
Repetition is not a single step.
-
grahamperrin said:
A single step … instead of multiple steps.
@lproven@social.vivaldi.net said:
… and repeat until …
Repetition is not a single step.
@grahamperrin Oh come off it. You could just record a macro, and do this in about 1kB.
-
@lproven@social.vivaldi.net you're still missing the point.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login