SAS log copy/paste includes line break - sas

While working inside SAS, I'll often highlight a dataset or variable name as it appears in the Log, copy it, and then paste it into the enhanced editor. The selection is from the middle of a single line of the log (no line breaks in the source). Unfortunately, pasting seems to always include a line break along with the seven or eight characters that I actually want. Is there a setting for me to change to avoid getting this extra line break?

Related

Delete every other line in Visual Studio Code regardless of content

A colleague has inserted duplicates for ~1200 entries into our database. They have sent me a text file containing both the originals and copies in alternating lines of CSV text. I've opened that up in VS Code with the goal of converting the lines representing duplicates into DELETE statements targeting our database. No line is truly identical to another—every two is a pair in which the data is the same other than the row ID.
I have found Stack Overflow entries for removing every other line when the line is empty, or when every other line is an exact copy of the previous line. I have not found an entry this scenario in which the lines have a difference. E.g. I tried using (.*)\n\1 w/ $1\n from another SO entry, which seems to target truly duplicate lines.
So how do I use VS Code to delete every other line regardless of content?
You can achieve this using Replace-All UI in regex mode.
Press command-F or control-F
Expand the arrow on the left of the Find display
Press the ".*" so that it's highlighted
Enter this for Find (top text field in the Find UI): (.*\n)(.*)\n (basically select two lines but save the contents of the first line in the regex system)
Enter this for Replace (following text field in the find UI): $1 (take the line saved from the Find regex and re-insert it)
Hit the Replace All button
Here's a similar SO question

ReportEvent: Logged messages run all lines together

I'm noticing that when logging a multi-line message using ReportEvent, it drops all line ends and runs the text together. For example, my MC file may have:
MessageId=
Severity=Informational
SymbolicName=MSG_TEST_MSG
Language=English
Some text
Another line of text.
Last line of text.
.
The message in Event Viewer shows all three lines run together.
If I put \r\n sequences in the text in insertion strings, those line ends do show up correctly in the logged message.
Also, if I use FormatMessageW to generate the text string of the above message, the line ends are correctly included in the text. They seem to be removed only when posting to Event Viewer.
I have not seen ANY reference to the fact that line ends are being dropped anywhere. Any idea? Is this just the way it is?
Thanks.
You have to use %n to force a "hard line break" inside the message.
Source:
%n
Generates a hard line break when it occurs at the end of a line. This
can be used with FormatMessage to ensure that the message fits a
certain width.
"Why does Format­Message say that %0 terminates the message without a trailing newline? Is it secretly adding newlines?" might also be interesting in this context.

How to get first displayed document line number if line wrapping is enabled?

I use SCI_GETFIRSTVISIBLELINE of Scintilla in order to get the first displayed line of the document.
Now, I enabled word wrapping mode by setting SCI_SETWRAPMODE to SC_WRAP_WORD. But SCI_GETFIRSTVISIBLELINE does not match the document line any more.
Is there a way to get the first displayed document line (also, how to know if the displayed line is part of a wrapped line)? Scintilla itself knows it, as the correct line number is displayed before the text (when enabling SC_MARGIN_NUMBER).
Update: The first document line of the visible line can be get by calling SCI_DOCLINEFROMVISIBLE with the result of SCI_GETFIRSTVISIBLELINE. However, detecting partial lines is still a problem.
The corresponding document line of first visible line can be get by calling SCI_DOCLINEFROMVISIBLE with the result of SCI_GETFIRSTVISIBLELINE: DOCLINEFROMVISIBLE(GETFIRSTVISIBLELINE())
The second part is a bit more tricky and seems a bit hacky to me:
First, I call SCI_WRAPCOUNT with the document line number of the first line and get the number of rows this line uses. If SCI_WRAPCOUNT()>1 it's a candidate for a partial line. The number of skipped lines can be calculated with SCI_DOCLINEFROMVISIBLE(SCI_GETFIRSTVISIBLELINE() + SCI_WRAPCOUNT() - 1) - SCI_DOCLINEFROMVISIBLE(SCI_GETFIRSTVISIBLELINE()).

CRichEditCtrl OnUpdate(): how to know the start and end positions when a paste is received?

I'm using a CRichEditCtrl to edit a computer language, and on every change to it I'm calling SetSelectionCharFormat on the current line of text (as reported by LineFromChar(-1)) to highlight the syntax. (EG: comments in green, section headings in a bigger font, compilation errors in red, etc.) Note this language doesn't have multi-line features such as a C comment where typing /* on one line makes following lines part of a comment too; for any given character change I only need to change the color of the current line.
It all looks like its working fine.
However there are some weird issues. One is, when multiple lines of text is selected from somewhere else, and pasted. My OnUpdate() is called but is naively assuming that the only line that potentially needs re-formatting is the one returned by LineFromChar(). That suffices when the user is typing character by character, but it means that after receiving a multi-line paste, the program only reformats the last line of the pasted text. How can it know where the start of the insert was?
OnUpdate is called inside the Paste operation.
It should be possible to subclass the RTF control and to intercept the WM_PASTE message. If WM_PASTE is not used internally it might be possible to use EM_PASTESPECIAL. If even tis message isn't sent, you have to interecept the Ctrl+V that causes the paste Operation.
Than you can determine the starting position of the paste operation.
Spy++ might be helpful to determine the message flow in the RTF control.

vim regex : multi-line edit and controlling the cursor position

A text file is formatted like this:
Section 4 Area B Unit 20
stuff i don't need...
stuff i don't need...
45990 - Title of Project that I want to save
line of text I need to keep
line of text I need to keep
2010-11 this line (starting with 2010) is not needed
stuff i don't need
Section 589 Area C Unit 1005
stuff i don't need...
stuff i don't need...
45990 - Title of Project that I want to save
line of text I need to keep
line of text I need to keep
2010-11 this line (starting with 2010) is not needed
stuff i don't need
and these sections repeat by the hundreds. The "stuff i don't need" lines are actually about 30 or so. I need to keep the association of the "Section..." line, "Title..." line and "line of text I need to keep" related to each other. So I was hoping to first destruct the text document down (linewise) to the stuff I need before operating on it further (character-wise). So I wrote this:
g!/\Section\s\d*\sArea\s\h\sUnit\s\d*\n\|^\s\{3}\zs\d*\s-\_.*\ze2010-11/d
After deleting I get the "Section.." line and the "Title..." line, but never the subsequent lines underneath the "Title.." line. Those subsequent lines vary from 4 to 8 lines, but the "2010-11" line is consistent and always what I no longer want.
You can see I tried using zs and ze to select what I do not want deleted. I think the selection is working because if I change the command to "2011-12" then there is no match and the (OR) half of the command does not return a result.
I think the fault might be the cursor position(?), but I'm not sure and my effort to fix that has failed.
Can anyone see my error?
Thanks!
Give this a whirl.
:silent! g/^Section/+ , /^\s\+\d\+ -/- d
:g/^\s\+2010/ , -/\nSection\|\%$/ d
:g finds every line matching start of the pattern, ! will revert the selection and command will get applied to these lines.
Would something like g/^Section.../normal! j2dd3jd} do?
If not you can use a search for the Title line inside normal!
You may need to enclose it in "exec" but may be much simpler to write a function.
Do you really need to use vim? Seems like job for Perl to me.
There are many ways to do t, I'm sure. I think this sequence of commands should work (ignoring comment lines that begin with double quote):
" global delete of line below 'Section' to line before 'Title'
g/^\s*Section/+1;/Title/-1delete
" global delete from date line to line before 'Section'
g/^\s*\d\d\d\d-\d\d/;/^\s*Section/-1delete
" go to top line of buffer
gg
" delete last chunk, from final date to last line
/^\s*\d\d\d\d-\d\d/;$delete