ChatGPT解决这个技术问题 Extra ChatGPT

Text Editor which shows \r\n? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 6 years ago. Improve this question

I'm looking for a text editor that can show me the actual carriage returns and newlines.

E.g. if I save this string: "This\rIs\r\nA\nString"

Instead of showing

This
Is
A
String

I'm looking for some text editor which will show

This\rIs\r\nA\nString

I believe a problem with my text-file parsing in a certain program is being caused by inconsistent newline/carriage return/both on the ends of lines.

I could just make a program which can read a file and display it with that formatting, but I figured it'd be easier if anyone knew of one that can already do it.

Thanks!

[EDIT] Forgot to specify I'm on Windows, and installing Cygwin isn't really an option. Otherwise I would use vi or vim. Also, if there's a way to do this in PSPad, which is already installed, it would be awesome if you knew that too. Thanks!

Cygwin is not a prereq for Vim. gVim runs fine on native Windows.

L
Liam

With Notepad++, you can show end-of-line characters. It shows CR and LF, instead of "\r" and "\n", but it gets the point across. However, it will still insert the line breaks. But you do get to see the line-ending characters.

To use Notepad++ for this, open the View menu, open the Show Symbols slide out, and select either "Show all characters" or "Show end-of-line characters".

https://i.stack.imgur.com/JcmqN.jpg


Thanks. Here I've been using PSPad for years, preferring it over Notepad++, and now it fails me. Not only that, but there's a forum post where people are pleading the author to add that feature, and he basically tells them to go away. Maybe I'll consider switching to Notepad++...
Thanks for reminding me that it is under View > Show Symbol. Tip: Notepad++ is also great for finding characters and replacing them with line breaks, see details at superuser.com/q/34451/169199
I really like the command od -c filename.csv. This one is working on the Terminal app. dr-palaniraja.blogspot.ca/2011/06/…
N
Nick Presta

In vi(m), check out:

:help 'list'
:help 'listchars' 

B
Blake

Sublime Text 3 has a plugin called RawLineEdit that will display line endings and allow the insertion of arbitrary line-ending type:

https://github.com/facelessuser/RawLineEdit


After installing the plugin, how do I activate it that is shows the line endings?
shift + ctrl + p is usually the way in Sublime to interact with plugins. Press these keys and start type the name of the plugin, you'll see the result.
j
jussij

On the Windows platform the Zeus editor has an option to display white space (i.e. View, White sapce menu).

It also has an option to display the file in hex mode (i.e. Tools, Hex Dump menu).


G
Glorfindel

You can get this in Emacs by changing the mode. For example, here is what things look like in Whitespace mode.

https://i.stack.imgur.com/xzELJ.png


M
MatBailie

I'd bet that Programmer's Notepad would give you something like that...


C
Cem Kalyoncu

Write a small program that does the trick. Depending on the language you use it takes between 10 seconds to 1 min. Faster than installing any application for sure. In command line with proper setup PHP

php -q

<?php $t=file_get_contents("filename"); echo str_replace(array("\n", "\r"), array("\\n", "\\r"), $t); ?>

I challenge you to write that program in any language in a second :-)
ok, a small typo, it should be 10
Don't vote me down, this is a valid solution, after all this is why PERL is created. Most importantly you can improve this method to search for any inconsistencies within a directory containing many files.
But I did say "I could just make a program which can read a file and display it with that formatting, but I figured it'd be easier if anyone knew of one that can already do it." (but I didn't vote you down).
J
Jarrett Meyer

vi can show all characters.


M
Matthew Talbert

Try Notepad++. It shows all characters. In addition, you could use the utility dos2unix to convert a file to all /n, or "conv" (same link) to convert either way.


d
dj_segfault

I am a huge fan of JEdit. It's very powerful, and cross-platform. There's a plugin available for it called Whitespace which can do what you want. If that's not enough, there's a hex viewing plugin and a hex editing plugin.


8 years later... looks a bit outdated until some theme/font size changes (GTK+ FTW) but it still compiles fine. Java based editor, pretty cool! Somewhat impressed by this little project, handles large files faster than anything I've tried so far, very fast in general, and feature packed. Good one!
P
PhiLho

SciTE does that very well with a single keystroke. It is also able to detect the most probably current line ending of the file (in case of mixed lines) and to convert them.
No need to install, lightweight, it can be used as a tool even if you don't want to give up your favorite editor.


N
NotMe

EmEditor does this. You can also customize what symbols actually display to show them.


g
gdelfino

If you have Mathematica, you can try with this command:

ReadList["filename.txt", Record, RecordSeparators -> {}] // InputForm

That will show all the /r and /n


R
Rook

Slickedit and Notepad2 also show them. In Slickedit you can customize all sorts of invisible characters (whitespace, tabs, CRs, line feeds, ...) and display them with any character you wish.


M
MBarbosaEng

The best for replace \n \t and more: Programmer's File Editor http://www.lancs.ac.uk/staff/steveb/cpaap/pfe/pfefiles.htm


The PSPad shows special characters: PSPad.com
w
wruckie

Sorry to join the bandwagon so late but in Windows 10, Notepad2 will show them. Choose from the menu View\Show Line Endings


C
Community

GVIM runs on Windows, and there is VIM for cmd.

Check http://www.vim.org/download.php

Also, a quick look through the docs or google, or some vimmy friends can help you to use VIM's quick search and replace to fix the problem you are having I believe.