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

Anomaly (perhaps bug) with " =" insert from 'normal' command

Expand Messages
  • Stahlman Family
    While developing a plugin, I noticed that several methods of inserting the char given by nr2char(128), which should yield the same results, work differently:
    Message 1 of 3 , Jan 4, 2005
    • 0 Attachment
      While developing a plugin, I noticed that several methods of inserting the
      char given by nr2char(128), which should yield the same results, work
      differently:

      The following methods work:
      Starting in normal mode...
      i^R^R=nr2char(128)^M
      i^R^R='?'^M
      :normal! i^R^R="\x80"^M

      The following, however, does not work. (It appears to interpret the inserted
      char as some sort of termcap code.)
      normal! i^R^R='?'^M

      (Note that the funny looking character between single quotes is equivalent
      to nr2char(128))

      Why does the one that fails fail, and why does the same method work when
      actually run from normal mode, as opposed to a normal command?

      Thanks,
      Brett S.
    • Bram Moolenaar
      ... The code 0x80 is used internally in Vim as a leader for special keys. Inserting 0x80 itself is still possible with a three byte code that stands for 0x80.
      Message 2 of 3 , Jan 5, 2005
      • 0 Attachment
        Brett Stahlman wrote:

        > While developing a plugin, I noticed that several methods of inserting the
        > char given by nr2char(128), which should yield the same results, work
        > differently:
        >
        > The following methods work:
        > Starting in normal mode...
        > i^R^R=nr2char(128)^M
        > i^R^R='?'^M
        > :normal! i^R^R="\x80"^M
        >
        > The following, however, does not work. (It appears to interpret the inserted
        > char as some sort of termcap code.)
        > normal! i^R^R='?'^M
        >
        > (Note that the funny looking character between single quotes is equivalent
        > to nr2char(128))
        >
        > Why does the one that fails fail, and why does the same method work when
        > actually run from normal mode, as opposed to a normal command?

        The code 0x80 is used internally in Vim as a leader for special keys.
        Inserting 0x80 itself is still possible with a three byte code that
        stands for 0x80. However, the translation depends on how a string is
        used, it's quite complicated. And it works differently after CTRL-R
        CTRL-R and on the command line. You'll have to figure out what does
        work by trial and error.

        --
        hundred-and-one symptoms of being an internet addict:
        238. You think faxes are old-fashioned.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
      • Stahlman Family
        ... From: Bram Moolenaar To: Stahlman Family Cc: Sent: Wednesday, January 05, 2005 2:56 AM
        Message 3 of 3 , Jan 5, 2005
        • 0 Attachment
          ----- Original Message -----
          From: "Bram Moolenaar" <Bram@...>
          To: "Stahlman Family" <brettstahlman@...>
          Cc: <vim@...>
          Sent: Wednesday, January 05, 2005 2:56 AM
          Subject: Re: Anomaly (perhaps bug) with "<C-R><C-R>=" insert from 'normal'
          command


          >
          > Brett Stahlman wrote:
          >
          >> While developing a plugin, I noticed that several methods of inserting
          >> the
          >> char given by nr2char(128), which should yield the same results, work
          >> differently:
          >>
          >> The following methods work:
          >> Starting in normal mode...
          >> i^R^R=nr2char(128)^M
          >> i^R^R='?'^M
          >> :normal! i^R^R="\x80"^M
          >>
          >> The following, however, does not work. (It appears to interpret the
          >> inserted
          >> char as some sort of termcap code.)
          >> normal! i^R^R='?'^M
          >>
          >> (Note that the funny looking character between single quotes is
          >> equivalent
          >> to nr2char(128))
          >>
          >> Why does the one that fails fail, and why does the same method work when
          >> actually run from normal mode, as opposed to a normal command?
          >
          > The code 0x80 is used internally in Vim as a leader for special keys.
          > Inserting 0x80 itself is still possible with a three byte code that
          > stands for 0x80. However, the translation depends on how a string is
          > used, it's quite complicated. And it works differently after CTRL-R
          > CTRL-R and on the command line. You'll have to figure out what does
          > work by trial and error.

          OK. I've found something I can use - putting the char into a register or
          variable first, then using that in the expression register, rather than the
          char in a literal string.

          e.g.,
          let @a=nr2char(128)
          :normal! i^R^R=@a^M

          Thanks,
          Brett S.
          >
          > --
          > hundred-and-one symptoms of being an internet addict:
          > 238. You think faxes are old-fashioned.
          >
          > /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          > /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/
          > \\\
          > \\\ Project leader for A-A-P -- http://www.A-A-P.org
          > ///
          > \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.