• Login
Community
  • Login

How to keep spacing when converting file from plain text to rich text?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 5 Posters 5.0k 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.
  • D
    Dimitri Poursanidis
    last edited by Dec 7, 2016, 3:33 AM

    Hi everyone. I have a file that comes out of really old software as .txt. It’s a list of names dates and times which are neatly arranged in columns while in plain text. I need to convert to rich text and when I do that I lose the columns.

    Is there a way to preserve the exact look of the .txt file but in rich text?

    1 Reply Last reply Reply Quote 0
    • P
      PeterJones
      last edited by Dec 7, 2016, 2:09 PM

      Not really a Notepad++ question – at least, I don’t know of a plugin in NPP that converts from plaintext to RTF (though it wouldn’t surprise me if there were one). But a quick search for “columns in rtf” lead me to a tutorial at http://www.pindari.com/rtf3.html and to http://stackoverflow.com/questions/5245630/setting-column-width-in-rtf , which might start pointing you in the direction of how to create a RTF table (and thus, a column).

      Other than rolling your own, or using the NPP plugin I don’t know about, you might consider something like a spreadsheet application, which can read a fixed-width text file as a spreadsheet, and can save to RTF; or use a scripting language, like Perl with its modules Text::CSV and RTF::Writer , or I assume there’s something similar for Python or your other favorite scripting language of choice.

      But I’m guessing a spreadsheet application would be your best bet for quick conversion of fixed-width tabular text into tabular RTF.

      1 Reply Last reply Reply Quote 0
      • G
        gstavi
        last edited by Dec 7, 2016, 3:11 PM

        First check if your original text file uses spaces or tabs.
        View --> Show Symbol --> Show White Space and TAB
        You can force spaces by selecting all text and:
        Edit --> Blank Operations --> TAB to SPACE
        Or force tabs with:
        Edit --> Blank Operations --> Space to TAB (ALL)

        Option 1:
        Force spaces, copy to RTF editor. In your RTF editor, switch to monospace font (Courier new) that should fix it.

        Option 2:
        Force TABS.
        Search and replace multiple tabs: \t+ to single tab \t.
        copy to RTF editor.
        Your RTF editor (MS Word?) may allow you to align the tab as you want.

        1 Reply Last reply Reply Quote 0
        • F
          Frank Orellana
          last edited by Dec 7, 2016, 4:24 PM

          Have you tried Right click -> Plugin commands -> Copy Text with Sintax Highlighting Or the same option from the menu:

          Plugins -> NppExport -> Export to RTF or
          Plugins -> NppExport -> Copy RTF to clipboard

          You have to select the text you want to export, it will work with simple text files too. You can do the first option and then copy in word for example.

          1 Reply Last reply Reply Quote 0
          • C
            cipher-1024
            last edited by Dec 7, 2016, 9:55 PM

            When you “convert to rich text” I’m assuming you’re pasting the data into something else (Word?). I think all you need to do to maintain the columns is set the font on the pasted data to a fixed-width font like courier.

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