CodeMirror : Start and end line numbers of the rendered DOM - codemirror

As far as i know, codemirror renders only few lines into the DOM, if a file has lots of lines. Is there any variable or function that could give me start and end line numbers in the rendered DOM?
For example, if i have 1000 lines in my file and if i am in mid of my file, code mirror might have rendered only lines from 400 to 500 into the DOM. How can i get those start and end line numbers?

You can get the line numbers range of the visible area by calling cm.getViewport().
From the docs:
cm.getViewport() → {from: number, to: number}
Returns a {from, to} object indicating the start (inclusive) and
end (exclusive) of the currently rendered part of the document. In big
documents, when most content is scrolled out of view, CodeMirror will
only render the visible part, and a margin around it. See also the
viewportChange event.

Related

How to remove the empty lines in an html file

In the image below there are empty lines before the head, body and closing /html tags and within the body tag I want to remove. How?
put cursor at end of line with text
press Shift-ArrowRight as many times till cursor at pos 1 selecting all newlines till next text
Ctrl+Shift+L to select all similar parts
ArrowRight
Backspace as much times as needed
Esc to leave multi cursor
According to your screenshot, you can try to reduce the line height to reduce the gaps between two successive lines.
Open Settings
Type Line height in the search bar
Specify your desired line height
And done.
Also you could try reducing your font size which would automatically decrease the line height thus reducing gaps in between successive lines.
Use \n\n* in the Find Widget (Ctrl+H) with the regex option (.*) icon enabled, replace with \n. Replace All.
or better change this setting:
// List of tags, comma separated, that should have an extra newline before them. `null` defaults to `"head, body, /html"`.
`HTML > Format: Extra Liners`
In your settings.json:
"html.format.extraLiners": "" // just leave empty
Now when you format the html file those empty lines above head/body/\html should be removed (select all and Command Palette: Format Selection).

How to set width of text marks in vega-lite / altair (text wrapping and line break) for long text

I am trying to display text over time using altair (vega-lite), which works fine using a layered chart, where one is created using the alt.Chart().mark_text() function to display the text.
The text though is multiple phrases and should be wrapped (with line breaks). How can this be done?
(I do not want to use fixed line breaks, e.g. \n, at distinct positions since the text wrapping should work with zooming too)
Not exactly what you want, but you can specify a character on which to break to a new line. When zooming, the text stays the same size, so it should always fit the view.
For example making a new line for every word:
.mark_text(lineBreak=' ')

MATLAB: page width line vs. publishing width

When I write code in Matlab I make sure it is within the page width line of demarcation. I thought the purpose of this line was because it signified the width of a page, but when I use the publish option on my code, it wraps about 6 characters to the left of the demarcation line, onto the next line, which makes the publishing ugly.
Is there any way to fix this by either changing the line position or the publishing width (preferably the latter)?
Here's what my editor window looks like:
And here's the resulting PDF page from publishing this code:
(notice the wrap-around in line #2)
Yes, I hit the same ugliness and this is the best I could get:
The first comment was put as line by line in the editor, while the second commented chunk was put as a long single line, and I think the publisher decides where to cut which is a neater result, not perfect though.

Tinymce - Bullet Points

Whenever we use Tinymce - Bullet Points or numbering within SSRS (Reporting Servicese) it appears there are extra spacing has been created at the bottom of the actual text. Is there a way around this? Has anyone else being having the same issue?
Within the HTML code it generates it doesn't seems like that there is any line spacing. However, as long as you insert a bullet point within the report it indicates about 1-2 line spaces at the end of the TinyMce article.
For an example if the entered text is as per below, there will be extra line spacing appearing at the end after the paragraph 3. This is only visual within the report writter. On web within the TinyMCE there are no spaces after the paragraph 03.
Doc Start
Paragraph 01
Paragraph 02
Bullet Points Start
-
-
-
Paragraph 03
Extra Spacing
Extra Spacing
Doc End

How to highlight a very long line using CodeMirror?

I'm using Codemirror to replace my textarea. If I set the value of CodeMirror to a very long line(with more than 50,000 words), Codemirror does not highlight all the words. Highlighting stopped somewhere and it seems like there is a maximum number of words per line that Codemirror can only handle. Do I need to set some options that will solve this issue?
Thank you.
Looks like 10 000 is the default:
maxHighlightLength: number
When highlighting long lines, in order to stay responsive, the editor
will give up and simply style the rest of the line as plain text when
it reaches a certain position. The default is 10 000. You can set this
to Infinity to turn off this behavior.
Source: http://codemirror.net/doc/manual.html#config