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

Re: vim: want control character in substitution string

Expand Messages
  • Paul
    ... This is great! I learn about nr2char as well as = at the same time! As Ben said, however, ^@ seems special and nr2char(0) doesn t seem to stick a ^@ in
    Message 1 of 6 , Mar 12, 2013
    • 0 Attachment
      On Mar 11, 4:48 pm, Gary Johnson wrote:
      >On 2013-03-11, Paul wrote:
      >> After much reading, I found that I can match ^@ with \%x00 in the
      >> search string, but I haven't found a way to specify control
      >> characters in the substitution string. Is there a way?
      >
      > You can use the nr2char() function as a replacement expression,
      > e.g.,
      >
      > :%s/\^D/\=nr2char(4)/g
      >
      > See
      >
      > :help sub-replace-expression
      > :help nr2char()

      This is great! I learn about nr2char as well as \= at the same time!

      As Ben said, however, ^@ seems special and nr2char(0) doesn't seem to
      stick a ^@ in the substitution. However, his trick of using \n in the
      substitution string gets around that.

      Thanks!

      --
      --
      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/groups/opt_out.
    • Charles Campbell
      ... Try reading ... Regards, C Campbell -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are
      Message 2 of 6 , Mar 13, 2013
      • 0 Attachment
        Paul wrote:
        > <snip> but I haven't found a way to specify control characters
        > in the substitution string. Is there a way?
        >
        Try reading

        :help i_ctrl-v

        Regards,
        C Campbell

        --
        --
        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/groups/opt_out.
      • Paul
        ... Thanks, Charles. I mention ctrl-v in my original post. -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below
        Message 3 of 6 , Mar 14, 2013
        • 0 Attachment
          On Mar 13, 10:45 am, Charles Campbell wrote:
          > Paul wrote:
          >> <snip> but I haven't found a way to specify control characters
          >> in the substitution string. Is there a way?
          >
          > Try reading
          >
          > :help i_ctrl-v

          Thanks, Charles. I mention ctrl-v in my original post.

          --
          --
          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/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.