how to stop sublime from trimming white space when copy/paste? - sublimetext2

It seems that sublime is trimming copied text from any white spaces, so when I try to copy/paste formated text the format breaks. Eg I have:
bla
blub
blab
I then copy the middle line, with white spaces and line break and insert it, I expect (and get in every other text editor I ever used)
bla
blub
blub
blab
but I get
bla
blub blub
blab
So, is there a way to get the expected behavior from sublime? I searched for a solution many times, without any result so far, and it drives me crazy.

Related

How to delete internal style (<style></style>) with bash script or command?

I'm working on my final automation to use CriticalCSS in every html page a project/folder has.
So far i was able to get so far to get criticalCSS into every html page with this workflow:
https://github.com/Macleykun/voxsiren.net/blob/main/.github/workflows/criticalCSS.yml
However, the only problem i'm having is that if new html is added/changed. And thus the criticalCSS changes.
The criticalCSS adds another tag to add the new CSS
If html is removed/no longer criticalCSS the css is left inplace.
My only goal is to do the following:
Detect a line starting with: and ending with
Remove the line (i prefer to have this in batch, but if someone suggests to do this in python/etc). That's also ok.
I hope someone is able to help me with this, and maybe even point out source material for me to look into to learn more!
I try to delete this kind of internal CSS: https://github.com/Macleykun/criticaltest/blob/main/404.html#L135
But want to keep this
https://github.com/Macleykun/criticaltest/blob/main/404.html#L11
up to
https://github.com/Macleykun/criticaltest/blob/main/404.html#L134
So that for example:
<style>
bal bla bla
</style>
is intact
but
<style>bal bla bla</style>
is removed
My only goal is to do the following:
Detect a line starting with: <style> and ending with </style>
Remove the line
So that for example:
<style>
bal bla bla
</style>
is intact but
<style>bal bla bla</style>
is removed
If you use sed, you have to ensure that a delimiter character which is part of the address expression is prepended with \:
sed -i '/<style>.*<\/style>$/d' file

How to prevent a line break between text elements where there is no whitespace

I'm trying to keep two text elements from being split apart by line breaks in an epub file (xhtml and css).
Example:
This is a line of text that reaches the end of the display and [12]what I don't want is for that superscripted part to be separated from the next word.
Which ends up looking like this:
This is a line of text that reaches the end of the display and [12]
what I don't want is for that superscripted part to be separated
from the next word.
I would like it to look like this:
This is a line of text that reaches the end of the display and
[12]what I don't want is for that superscripted part to be
separated from the next word.
Some software on my pc keeps the superscripted <sup>[12]</sup> and the what together, but my Sony ebook reader doesn't. Other e-readers may do the same. I'd like it to consistently keep the superscripted part together with the next word and avoid a line break between them.
I've looked at quite a few similar questions, but can't find anything that matches this problem.
I'd prefer to deal with this problem via css, rather than editing a huuuuuge bunch of files by adding tags throughout it, which would be further complicated by the fact that the word after each superscripted part can be any word, ruling out a simple search and replace.
In a similar vein, I'd also like to extend the "keeping things together" bit when the next word is "I" or "A" or "a" or any short 2-letter word, so a sentence like
bla bla bla bla bla bla bla bla bla bla [35]in the simplest way imaginable.
would line break in either of these ways:
bla bla bla bla bla bla bla bla bla bla [35]in the
simplest way imaginable.
bla bla bla bla bla bla bla bla bla bla
[35]in the simplest way imaginable.
but NOT break like:
bla bla bla bla bla bla bla bla bla bla [35]
in the simplest way imaginable.
bla bla bla bla bla bla bla bla bla bla [35]in
the simplest way imaginable.
Is there perhaps a way to set some margin property or whatever so that any superscript tag must be a minimum distance removed from the right hand margin, or else it will be moved to the next line? I could then set that minimum distance to encompass the tagged part plus an additional 2 or 3 character widths.
Something like the page break after : avoid; property but working at the line (not page) level would be great. Or even an orphan: 5; type property for lines might do the trick.
I'm thinking (and hoping) that both the problems I've outlined above can have one and the same solution.
For the benefit of others trying to solve similar sticky problems, have a look at the available "special" space characters. These are the pages on wikipedia I checked out:
https://en.wikipedia.org/wiki/Space_%28punctuation%29
and
https://en.wikipedia.org/wiki/Zero-width_joiner
There's also the "thinspace" and the "hairspace", in case you're looking for a "space" that is narrower in size than the regular space.
There is no CSS solution that does not require changes to the markup or content. The reason is that there is no element to attach CSS styles to. CSS has no properties that would control line breaking behavior depending on the characters in content (like “don’t break after ‘]’ characters”); maybe it will some day.
There are several ways to prevent line breaks, such as the nonstandard but well-supported nobr element, the CSS setting white-space: nowrap (set on an element inside which automatic line wrapping is to be disabled), and the special character zero-width no-break space (ZWNBSP). While all of these work generally well in modern web browsers, they have problems in ebook readers. You need to analyze which user agents are important and test the various approaches on them. Note that ZWNSP is unsafe in the sense that when not supported (in some ebook readers and in very old web browsers), it creates a problem that is more serious than the one being solved (an odd-looking symbol is shown). The other approaches may fail, but just in the sense of not having any effect.
After choosing the approach, consider whether it can be implemented using client-side JavaScript, i.e. code that runs after the page has loaded and may modify the document tree e.g. by inserting new elements. For example, if the issue is with bracketed expressions and brackets are not used otherwise, the code could just insert a special character after the closing bracket or recognize the next word and wrap the bracket and the word in an element.

Can't get new line to work using echo in bash script

This is driving me nuts.
nl=$"\n"
message="bla bla $some_var such $another_var ${nl} wow $another_var"
echo -e "$message" > file.txt
Just prints:
bla bla some_var such another_var wow another_var
I want it to print:
bla bla some_var such another_var
wow another_var
SOLUTION: don't use \n when outputting to html file use <br/> instead LOL
Your comment on your original question makes me believe you are printing HTML to a file. How are you checking whether it has newlines? If you want to get actual newlines on your website, you should use <br> instead of \n.
$"bla" is used for translations using the current locale in bash. What you want is the $'bla' notation which knows of these backslash escapes.

Print text from specific line number of an HTML file

I'm trying to find a way to print the text from a specific line number of an HTML file.
I've found ways to print the line numbers of a text search, but I want to do the reverse, printing the text of the line number, where the line number stays constant but the text there may change.
One way
$ cat foo.txt
dog
bird
monkey
$ sed '2!d' foo.txt
bird
In simple terms, if not line 2, delete

how to paste text to left of original text like ultraedit column mode

I have below original text:
a:1
b:2
c:3
d:4
I want to paste below content into right side of original text area
a:5
b:7
e:10
Result should be:
a:1 a:5
b:2 b:7
c:3 e:10
d:4
it is easy to finish it by ultraedit columnn mode. but how to do in sublime quickly?
You can use column selection.
Go to the end of first line, and press ctrl+shift+down (or ctrl+alt+down on Windows and Linux) as many times as you need. Then add the number of spaces that you need, and paste your text.
Sublime Text 2 trick shift+ctrl+L split lines