Community
    • Login

    Keep line endings on paste (no LF to CRLF or CRLF to LF)?

    Scheduled Pinned Locked Moved General Discussion
    6 Posts 3 Posters 11.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • FointardF
      Fointard
      last edited by

      Hi NPP community.
      First of all this is great software that I’ve been using daily for many years now, thx for developping it !

      As the title suggests, I’d like to know how to paste content from one file to another without having the line-endings automatically converted to whatever the destination file mode is.
      If I copy/paste a snippet from a unix (LF) file to a windows one (CRLF), the line-endings are automatically converted to CRLF and I think NPP should make it possible to disable this behavior.

      My use case is the following : I’m working with Git, trying to manually apply a patch which affects multiple files. Those files can either be LF or CRLF as the repo contains code for linux and for windows, resulting in a mixed line-endings patch.
      That patch being very big, I need to cut/paste parts of it from one file to another to keep track of my progress.

      But NPP keeps messing with line-endings, making parts of my copy/pasted patch broken as I can’t apply those cleanly to my repo.

      I understand the current behavior is what’s needed in most conventional use cases, but adding an option to leave line-endings untouched on copy/paste would make my life so much easier right now.
      Any chance this issue might be addressed at some point ?

      U guys have a nice dev.
      Fointard

      Meta ChuhM 1 Reply Last reply Reply Quote 1
      • Meta ChuhM
        Meta Chuh moderator @Fointard
        last edited by Meta Chuh

        welcome to the notepad++ community, @Fointard

        you have various options to preserve, convert or mix your line endings in notepad++:

        • if you want to preserve the line endings while copying a snippet from a linux file, open the source file in notepad++, select the section you need, and go to edit > paste special > copy binary content as seen at the screenshot below.
          then use edit > paste special > paste binary content on the other file, where you want to paste this snippet.

        Imgur

        • if you want to use the default copy paste, you can switch your current windows document to unix lf, before pasting your linux eol clipboard content to it.
          double click on windows (cr lf) at the lower right of the notepad++ status bar, and select unix (lf) as seen at the screenshot below.

        Imgur

        • if you want to convert your whole new document, where you have pasted the unix (lf) content to, after pasting, go to edit > eol conversion > unix (lf)

        Imgur

        i hope this is of service to you.

        1 Reply Last reply Reply Quote 3
        • FointardF
          Fointard
          last edited by

          THANK YOU @Meta-Chuh
          You just saved my day (and you did it quick !).
          That ā€œPaste binary contentā€ was all I needed. Now what I need is a macro/shortcut that will automate my workflow but that’s the easy part.

          Thank you again, long live NPP !

          1 Reply Last reply Reply Quote 1
          • PeterJonesP
            PeterJones
            last edited by

            @Meta-Chuh ,

            Thank you!

            I had never noticed the Edit > Paste Special binary options. My very first question here was because NUL characters were getting converted to spaces when going through the copy buffer; at the time (v6.8.6), we had to do a regex/copy-paste/anti-regex sequence to protect certain characters.

            My three-year-old question now has the correct, built-in answer.

            Now I’m curious when it was added: per a search of the commits, ā€œPaste Binary Contentā€ was included in March 2011, which was long before the Oct 2015 v6.8.6 release. Looking through release history based on dates, and then confirming with release page: v5.9 included Copy/Cut/Paste Binary Content feature for the first time.

            Apparently, the regulars either didn’t think of it when I asked the question, or didn’t know about it / hadn’t used it. Maybe it was because I couched the original question in TextFX conversions.

            Time to go re-vivify the topic briefly.

            Meta ChuhM 1 Reply Last reply Reply Quote 1
            • Meta ChuhM
              Meta Chuh moderator @PeterJones
              last edited by Meta Chuh

              you’re very welcome @PeterJones and thanks for the thanks from teacher to alumnus šŸ˜ƒšŸ‘

              last time i recall copy paste binary content was mentioned, was a pregnancy ago, after i found out that @chcg had ported NPP_HexEdit to x64.

              i got a bit over-euphoric when i heard this and asked if c/p binary could be implemented to hexedit as well.

              btw: a long overdue thanks to @chcg for adding it to the enhancment list back then.

              Time to go re-vivify the topic briefly.

              i did the same right now, revisited both yours and mine šŸ˜‰šŸ‘

              and yes, it’s really strange that paste special and copy binary content is almost inexistent if i do a forum search, considering it’s been there since 5.9 as you’ve found out (thanks for checking šŸ‘)

              1 Reply Last reply Reply Quote 1
              • Meta ChuhM
                Meta Chuh moderator
                last edited by

                and thanks for the thanks from teacher to alumnus šŸ˜ƒšŸ‘

                side note:
                it feels nice to get a thanks from a teacher (peter) to a student (me)
                hope the who is who didn’t get mixed up in it’s context above.

                1 Reply Last reply Reply Quote 2
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors