0

can I insert a new line when multi-editing in Notepad++? I sometimes have to convert a list of codes like this:

code01,code02,code03

to a list like this:

code01

code02

code03

Multi-editing works well to backspace out the commas but when I try to enter a return to start the next line, multi-editing turns off.

I've looked around for documentation but can't find anything. I know I can use the find/replace dialogue to replace the commas with \n or \r but there are other more complicated situations where a multi-line new line creation would help me. Thanks in advance, Graham

  • but there are other more complicated situations Could you post some examples? – and31415 Jun 3 '14 at 17:03
  • The other stuff is just more of the same but similar. Techie007's answer does what I was after but thanks for your offer of help. – axolotl66 Jun 3 '14 at 19:17
0

Instead of using the Enter key, type the "carriage return" character (ASCII 13).

You can do this by holding Alt and typing 013 on the numeric keypad (while NumLock is on), and when you release the Alt key, it'll insert a carriage return.

Just tested in NP++ v6.6.3 and it worked. :)

  • Thanks, that's just what I was after! So simple when you know the answer....!!!! Cheers, Graham – axolotl66 Jun 3 '14 at 19:13
0

I had the same problem and the solution proposed by Ƭᴇcʜιᴇ007 is ok for certain text encoding EOL (end of line) usually targeted to a specific OS platform.

So depending on what operative system you are targeting you can use alternatively one of the following:

  1. Alt + 013 that is equivalent to \r, as specified in Ƭᴇcʜιᴇ007 answer (usually for Mac);
  2. Alt + 010 that is equivalent to \n (usually for Unix / Lilnux);
  3. Alt + 013 and Alt + 010 if you want to insert both \r\n chars (for Win).

Using for the wrong EOL char for example Alt + 013 that means \r in case you are targeting a different OS platform you might have the need to convert the end of line chars to the correct type used in that platform where your code will run. In case you need to do so go to Menu > Edit > EOL Conversion (End Of Line Conversion) and from the sub menu choose the right platform your code is targeted to.

Also if you want you can assign to your preferred EOL conversion command a keyboard shortcut.

A further and more complex alternative would be to implement a macro to find and replace a customized placeholder when you are coding.

How to:

  1. Start recording a new macro;
  2. Recall the find and replace dialog;
  3. Insert into the "Find" field a char that you never use, for example in my case I used the section symbol "§";
  4. Insert into the "Replace" field the newline char accordingly with the used OS platform, in my case it is "\r\n";
  5. Into the find and replace window, check the "Extended" check box. This way n++ will interpret correctly the \r\n transforming it into the new line symbol: if you don't check this option n++ inserts just \r\n, literally into the text;
  6. Press the replace all button;
  7. Stop macro recording;
  8. Save the macro and assign to it an unused keyboard shortcut (for ex. Alt+Enter).

The code of the macro is as the following:

<Macro name="Replace &#x00A7; with newline" Ctrl="no" Alt="yes" Shift="no" Key="13">
    <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
    <Action type="3" message="1601" wParam="0" lParam="0" sParam="&#x00A7;" />
    <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />
    <Action type="3" message="1602" wParam="0" lParam="0" sParam="\r\n" />
    <Action type="3" message="1702" wParam="0" lParam="768" sParam="" />
    <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
</Macro>

Of course it is possible to set the "find" field into find and replace with different char instead the § and a different EOL - newline char (the string literal \r\n) into the replace field to adapt it to the operative system platform that you have to target your code.

You can place the macro into the shorcuts.xml file into the notepad++ directory.

Once the macro is saved, how to use it: 1. Press Ctrl and click with the mouse a usual into the multiple points where you want to insert the new line; 2. Insert the § symbol or the one you choose as placeholder; 3. Use the appropriate key combination to activate the macro (in my case Alt+Enter); 4. The macro replaces all occurrence of the placeholder "§" with "\r\n" (or anything you've chosen to).

In synthesis you have to press first Shift + § and then Alt + Enter

Done

Advantages: all proposed solutions work on all platforms, (take care of changing the EOL char accordingly!); The Macro solution has the disadvantage that you have to choose one char placeholder symbol you don't use for anything else.

What to choose is a question of personal preferences.

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.