Line breaks using dlmcell in Matlab - shows up in Notepad++ but not Notepad - matlab

I am using the function dlmcell in Matlab to output text. I want text on a new line each time I append using dlmcell.
When I open my written document in Notepad++, each snippet of text is on a new line as I want it. However, opening it in Notepad that comes with windows, everything is on the same line. Can somebody tell me why this is, and how to fix it?

I'm assuming you're using the string \n to declare a new line in your output. For Notepad++ this is sufficient, because it interprets a new line just with \n. For the Windows Editor you need to include the carriage return also:
substitute:
\n with \r\n
This way not just a new line is created, it also tells the editor to actually continue on the next line.
To illustrate what I mean, open your output file with Notepad++ and activate View > Show Symbol > All characters and you will see something like:
I wrote this with Notepad++ and it automatically adds CR (carriage return) and LF (line feed) at the end of every line. Matlab doesn't if you don't tell it. So your output file only contains LF without the above mentioned substitution.
I've had a look into dlmcell, which is a FEX-function. In the current version \r\n is implemented actually. Do you have the newest version of that function (Download)? If not, something else must be wrong, please post some code.

Related

How to convert embedded CRLF codes to their REAL newlines in Vscode?

I searched everywhere for this, the problem is that the search criteria is very similar to other questions.
The issue I have is that file (script actually) is embedded in another file. So when I open the parent file I can see the script as massive string with several \n and \r\n codes. I need a way to convert these codes to what they should be so that it formats the code correctly then I can read said code and work on it.
Quick snippet:
\n\n\n\n\nlocal scriptingFunctions\n\n\n\n\nlocal measuringCircles = {}\r\nlocal isCurrentlyCheckingCoherency
Should covert to:
local scriptingFunctions
local measuringCircles = {}
local isCurrentlyCheckingCoherency
perform a Regex Find-Replace
Find: (\\r)?\\n
Replace: \n
If you don't need to reconvert from newlines to \n after you're done working on the code, you can accomplish the trick by simply pressing ctrl-f and substituting every occurrence of \n with a new line (you can type enter in the replace box by pressing ctrl-enter or shift-enter).
See an example ctrl-f to do this:
If after you're done working on the code you need to reconvert to \n, you can add an invisible char to the replace string (typing it like ctrl-enter invisibleChar), and after you're done you can re-replace it with \n.
There's plenty of invisible chars, but I'd personally suggest [U+200b] (you can copy it from here); another good one is [U+2800] (⠀), as it renders as a normal whitespace, and thus is noticeable.
A thing to notice is that recent versions of vscode will show a highlight around invisible chars, but you can easily disable it by clicking on Adjust settings and then selecting Exclude from being highlighted.
If you need to reenable highlighting in the future, you'll have to look for "editor.unicodeHighlight.allowedCharacters" in the settings.

Changing the default display of line breaks in search window?

I recently switched from Textwrangler to BBEdit. I use these editors to perform large multi-file GREP-search mainly. But in BBEdit I noticed that line breaks automatically get converted to \n in the search window, and that makes in very hard for me to get an overview of the search I'm about to perform, when everything is on one line.
When I copy a text with line breaks, for example
Line
Line
Line
and paste it in the search window, it looks like this:
Line\n\nLine\n\nLine
In TextWrangler I was able to see the line breaks as line breaks, not \n. How can I change that in BBEdit?
Thanks!

Visual studio code end of line setting (file with inconsistent line endings)

Is it possible to keep original end of lines in the file?
(I use visual studio code to edit files on a linux server through SAMBA)
There is a button at right bottom to choose either LF or CRLF,
but it replace all the end of lines in the file.
example:
line1 \r\n
line2 \r\n
line3 \n
No, it is not possible in VSCode to preserve the original line endings when they are not the same throughout a file. Internally, for each file, VSCode only stores a single _eol value, and when multi-line text is requested, inserts it between every line on the fly.
See, for example, method getText() in mirrorTextModel.ts. MirrorTextModel is a base class of ExtHostDocumentData, which implements the TextDocument entity exposed in the API.

How can i hinder Eclipse from inserting CRLFs?

I just reinstalled Eclipse Juno.
The problem i have is when i create a new file and start writing, CRLFs are inserted on Return.
Second case: When i fully mark the text of a file (without CRLFs) ans COPY them into another file (i use CRTL+A and DEL to get rid of the file contents and then PASTE i get the file content with CRLFs!)
The resulting file looks like:
Test blah CRLF
Line two ... CRLF
CRLF
How can i get rid of them?
Solution to this is to configure Eclipse accordingly.
Windows->Preferences->General->Workspace
In the right lower corner there is a setting called "New text fiel line delimiter" which i had to switch from Windows to Unix.
The already CRLF prensent i had to remove using Eclispe->File->Convert line delimiters to ->Unix .

How to remove empty line from the end of new class - Eclipse

I currently work on Eclipse Juno 4.2 (but problem is connected with older versions of eclipse as well) and I found an irritating issue. When we try to create new class with a default formatter settings, eclipse put an empty line at the end of file.
I tried to figure out by myself how to remove this annoying line and search in formatter options. I found option that could help solve my problem but i found it's disable by default.
My question is: How to get rid of this line?
It's not really an empty line. It just appears that way in Eclipse.
When you see the blank line in Eclipse, it means that the last line of the file is terminated by a new line character. That is, the last characters in your Java file are probably }\n (on *nix, with LF line endings) or }\r\n (CRLF line endings on Windows), followed in each case by the end of the file.
You can prove this to yourself using tail or cat on *nix. If the prompt appears on the same line as the last line of code, then there's no trailing new line. If the prompt appears on a separate line, then there is a trailing new line character. If there's a blank line before the prompt, then there's an empty line in the file.
If the above doesn't convince you, use a hex editor. :o) An empty line would appear as two consecutive line endings: \n\n or \r\n\r\n (on *nix and windows respectively).
There's nothing wrong with the last line of your file having a new line character at the end. In fact, it's a good idea to leave it there, because some tools will warn if it's not there. These tools include Checkstyle (there's an Eclipse Checkstyle plugin) and diff.
Eclipse allows you to put the cursor there in case you want to add new content to the end of the file. (This isn't often needed in Java, because most people don't put more than one top-level type in a file.)
Best just to leave it there, and get used to Eclipse showing it.