I have a bash script which parse text files. In these text files some lines contains a new line character, when I open the file with Vim it looks like this:

data 1=part 1 ^M part 2
data 2=part 1

I inserted the ^M character in vim thanks to Ctrl+vEnter.

The script will consider each line of the file as the description of a data and will understand that data 1 is a text containing a new line.

Now my coworked need to create the same kind of file but he won't use Vim:

  • If he uses enter instead of Ctrl+vEnter that will create a new line and my script will not work properly (considering both part of data1 as two separate data lines).
  • If he insert \n or \r manually the script will considering that data 1 is a single line of text containing the character \ followed by n or r without special meaning.

How can he produce the same file with an editor like notepad++? I.e. how can he add a new line character which will not be interpreted by notepad++

Note that my question is about doing it with notepad++ because modifying the script would be an enormous inconvenient.

  • Which line break character/type is being used in the file to separate the records onto their own lines? CR, LF, both? – Ƭᴇcʜιᴇ007 Dec 1 '16 at 18:03
  • @Ƭᴇcʜιᴇ007: The files are created on windows thus I'd say the standard CR + LF – statox Dec 1 '16 at 18:04
  • So you're trying to insert/show the ASCII character "ALT+13" (just CR) instead of treating it as a CR/LF, correct? – Ƭᴇcʜιᴇ007 Dec 1 '16 at 18:08
  • @Ƭᴇcʜιᴇ007 You're probably kind of right but alt+13 insert a musical note ♪ on my setup – statox Dec 1 '16 at 18:14
  • Sorry, it'd be alt+013 in Windows. :) Honestly I think you're out of luck, as NP++ seems to always treat CR as a new line, whether it includes an LF or not.. maybe a plugin to change that, but I can't find one off hand. Maybe someone else knows. :) Good luck! – Ƭᴇcʜιᴇ007 Dec 1 '16 at 18:17

^M is used for displaying the CARRIAGE RETURN (ASCII 13, 0x0D) character in vim.

You can type it with Alt + 013 on the numpad in Notepad++. However, Notepad++ seems to always place a newly typed carriage return at the end of an existing line break, regardless what line break style is set for the file. So I would not recommend Notepad++ for this.

It is worth noting that mixed line breaks in a single file will always lead to problems when working with it. Some tools will even convert all line breaks to a certain format without the user's consent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.