Loading ...
Sorry, an error occurred while loading the content.

Re: how to hidden the ^M without change the file

Expand Messages
  • Conner McDaniel
    ... - Conner ... -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For more
    Message 1 of 6 , Jul 13, 2014
    • 0 Attachment
      :help 'list

      - Conner


      On Mon, Jul 14, 2014 at 09:21:47AM +0000, fengidri wrote:
      >when the file has '\r\n' and '\n', I donot want see the ^M, but I donot
      >want change the file.
      >
      >thanks!
      >feng
      >
      >--
      >--
      >You received this message from the "vim_use" maillist.
      >Do not top-post! Type your reply below the text you are replying to.
      >For more information, visit http://www.vim.org/maillist.php
      >
      >---
      >You received this message because you are subscribed to the Google Groups "vim_use" group.
      >To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      >For more options, visit https://groups.google.com/d/optout.

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Tim Chase
      ... There are a couple things: 1) Vim usually auto-detects the r n line endings if *all* the lines have them. If some are missing the r portion, you ll
      Message 2 of 6 , Jul 13, 2014
      • 0 Attachment
        On 2014-07-14 09:21, fengidri wrote:
        > when the file has '\r\n' and '\n', I donot want see the ^M, but I
        > donot want change the file.

        There are a couple things:

        1) Vim usually auto-detects the "\r\n" line endings if *all* the
        lines have them. If some are missing the "\r" portion, you'll see
        the ^M characters at the end of the line. To remedy this, I'd be
        tempted to do the following:

        vim mixed.txt
        :%s/\r$
        :w ++ff=dos

        which will ensure that every line ends in "\r\n". Once the file is in
        DOS line-ending format, you shouldn't see them unless you have
        *redundant* line-endings ("\r\r\n"). This does technically change
        the file (which you say you don't want to do) but it ensures that
        EVERY line has "\r\n".

        2) If you really are crazy and *do* want mixed line-endings (some with
        "\r\n" and some with just "\n") then you can hide them with

        :hi SpecialKey ctermfg=0 guifg=bg

        where the values are whatever is output by

        :hi Ignore

        This does have some collateral damage where other embedded control
        characters will be hidden (i.e., black-on-black or the like). The ^M
        characters are still there, just hidden.

        -tim


        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • John Beckett
        ... I recommend reading the details: http://vim.wikia.com/wiki/File_format John -- -- You received this message from the vim_use maillist. Do not top-post!
        Message 3 of 6 , Jul 13, 2014
        • 0 Attachment
          fengidri wrote:
          > when the file has '\r\n' and '\n', I donot want see the ^M,
          > but I donot want change the file.

          I recommend reading the details:
          http://vim.wikia.com/wiki/File_format

          John


          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Christian Brabandt
          ... Best, Christian -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying to. For more
          Message 4 of 6 , Jul 14, 2014
          • 0 Attachment
            Am 2014-07-14 11:21, schrieb fengidri:
            > when the file has '\r\n' and '\n', I donot want see the ^M, but I donot
            > want change the file.
            >
            > thanks!
            > feng

            You could use concealing:

            :syntax match ConcealCR /^\%x0d$/ conceal
            :set conceallevel=2 concealcursor=nv

            Best,
            Christian

            --
            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          • fengidri
            when the file has r n and n , I donot want see the ^M, but I donot want change the file. thanks! feng -- -- You received this message from the vim_use
            Message 5 of 6 , Jul 14, 2014
            • 0 Attachment
              when the file has '\r\n' and '\n', I donot want see the ^M, but I donot
              want change the file.

              thanks!
              feng

              --
              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            • fengidri
              I find the way: call matchadd( Ignore , r ) ... -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text
              Message 6 of 6 , Jul 14, 2014
              • 0 Attachment
                I find the way:
                call matchadd("Ignore", "\r")
                于 2014年07月14日 08:05, Christian Brabandt 写道:
                > Am 2014-07-14 11:21, schrieb fengidri:
                >> when the file has '\r\n' and '\n', I donot want see the ^M, but I donot
                >> want change the file.
                >>
                >> thanks!
                >> feng
                >
                > You could use concealing:
                >
                > :syntax match ConcealCR /^\%x0d$/ conceal
                > :set conceallevel=2 concealcursor=nv
                >
                > Best,
                > Christian
                >


                --
                --
                You received this message from the "vim_use" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/d/optout.
              Your message has been successfully submitted and would be delivered to recipients shortly.