Community
    • 登入

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

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    5 貼文 5 Posters 5.3k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Dimitri PoursanidisD
      Dimitri Poursanidis
      最後由 編輯

      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 條回覆 最後回覆 回覆 引用 0
      • PeterJonesP
        PeterJones
        最後由 編輯

        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 條回覆 最後回覆 回覆 引用 0
        • gstaviG
          gstavi
          最後由 編輯

          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 條回覆 最後回覆 回覆 引用 0
          • Frank OrellanaF
            Frank Orellana
            最後由 編輯

            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 條回覆 最後回覆 回覆 引用 0
            • cipher-1024C
              cipher-1024
              最後由 編輯

              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 條回覆 最後回覆 回覆 引用 1
              • 第一個貼文
                最後的貼文
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors