reformat blocks of text to line width - text-editor

As a programmer, I frequently find myself using text editors rather than proprietry editing tools (like word) to smudge out
blocks of text. But I and I'm sure many of you with OCD find it rather annoying when you need to edit a line above
what you've already written, causing a jutting line out from your nicely formatted lines. I have had no other solution to this
problem other than re-new-lining every single line thereafter to correct the margins.
for lack of a better definition: Is there a better way of reformatting blocks of text to a given line width. if possible by selection
as well?
possible scenario:
Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
becomes:
Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
according to a predefined setting.
I am using sublime text 2.

I use Sublime Text 3, select text, go to Edit -> Wrap -> ...
hope that works in version 2

Related

How can I make a (first) letter uppercase in tinyMCE?

We use the latest version of tinyMCE.
We have the following text - example given - take care at the first letter after the end of a proposition:
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. duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
How can we scan the text and properly capitalise the first letter in the proposition/phrase?

rmarkdown: Custom indentation with static and dynamic content

I generate text with dynamic and static content. I would like to achieve this
(the dynamic content "Apples", "Gagaga ....." should be justified unlike in the picture. I just dont know how to achieve this in Writer)
I would like to achieve the indentation of the dynamic content.
I tried the following solutions but they don't work
---
title: ""
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
df<-data.frame(name=c("Apples", "Gagagagagagaga Long 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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."))
```
Static content: `r df$name[1] `
\
\
Static content: `r df$name[2] `
\begingroup
\noindent%
\begin{tabular}{#{}ll#{}}
Static content: & `r df$name[1] `\\
Static content: & `r df$name[2] `\\
\end{tabular}
\endgroup

Remove link tag that have some URL with Cheerio

I have an HTML code that I am processing with the Cheerio library, I need to delete the tag "http://www.example.com'> example " for the links that refer to a domain (in this case "http://www.example.com") but not the other links. In addition, in the case of the link label being deleted, the keyword that contains it must be maintained.
Example origin:
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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Example result:
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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Thank you!
I found the solution to my problem:
$('a').each(function() {
if ($(this).attr("href").indexOf('example.com') > -1) {
$(this).replaceWith($(this).html());
}
});
If I use the .remove() function it delete the complete tag, but with this solution it only delete the link tag that contains example.com in the href attr.
I hope this helps to other people with the same challence. ;)
It sounds like you want:
$('a[href*="www.example.com"]').remove()
or
$('a[href*="www.example.com"]').each((i, a) => $(a).replaceWith($(a).text()))

sublime text 3 select lines after finding a specific word

I have this text:
Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
I want in Sublime text 3, to select the lines that have "Lorem" without using the mouse.
Thank You, for the help.
Your text were pasted in one line in Sublime Text so i manually moved each sentence into a single line. Then I used this regex:
^.*\b(Lorem)\b.*
In the search function, getting this result:
Click for fullsize
Note that you will have to enable the Regular Expression in the bottom left corner.

Adding empty line between paragraphs with VIM

I'm looking for a single command to turn this:
Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum. Ipsum dolor sit
amet, consectetur adipisicing elit. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
into this:
Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum. Ipsum dolor sit
amet, consectetur adipisicing elit.
Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
Any suggestions?
If it's wrapped, that means a paragraph is actually only ONE line, and you're actually adding a single blank line between lines. try:
:g/.\n\n\#!/norm o
It's explained here .
And if it's not wrapped (means there're many lines in ONE paragraph), I've no idea how to do it, either. But according to the explaination of that site, you can try to manage it by writing your own regex rules !
:%s/\.\s*\n\(\S\)/\.\r\r\1
Obtains the desired result with the given sample (which contains a pesky trailing space).
We search for a dot followed by zero or more whitespace characters (because of the pesky trailing space), followed by a newline, followed by a non-whitespace character that we capture.
We replace with a dot, followed by two newlines and the non-whitespace character that we captured earlier.
(edit)
The following substitution is more generic and suits your non-specified requirements:
it doesn't care about how each "paragraph" ends
it respects indenting as well
so…
:%s/\s*\n\(\s*\S\)/\r\r\1
If you want to normalize your buffer and remove indenting:
:%s/\s*\n\(\s*\)\(\S\)/\r\r\2
or, with less backslashes…
:%s/\v\s*\n(\s*)(\S)/\r\r\2

Resources