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

Passing Ctrl-Y and Ctrl-E as function argument.

Expand Messages
  • Benoit Thomas
    Hi, In my .vimrc, I have function to have smooth scrolling to replace Ctrl-U and Ctrl-D (otherwise I loose context). The implementation I took from the net was
    Message 1 of 4 , Jan 20, 2013
    • 0 Attachment
      Hi,

      In my .vimrc, I have function to have smooth scrolling to replace Ctrl-U
      and Ctrl-D (otherwise I loose context). The implementation I took from
      the net was using an integer for the direction, something like

      if a:up
      let action="\<C-Y>"
      el
      let action="\<C-E>"
      en

      which was working great. But instead of passing 0 or 1 for the function
      up value, I tried to modify the function to pass the action directly. I
      then change the mapping to:

      no <C-U> :call SmoothScroll("\<C-Y>")<CR>
      no <C-D> :call SmoothScroll("\<C-E>")<CR>

      While this works for C-U, hitting C-D returns the following error:

      E114: Missing quote: "\")
      E116: Invalid arguments for function SmoothScroll

      I am not sure why I get this error, nor how to fix it. I also tried many
      variations for writing Ctrl-E without success.

      Any help would be greatly appreciated.
      Thank you,
      Ben.

      --
      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
    • John Little
      ... The ctrl-e is being interpreted as it would on the command line, see ... Any of V, Q, B, H, W, R, J, C may give the same kind of trouble, as will Y When
      Message 2 of 4 , Jan 20, 2013
      • 0 Attachment
        On Monday, January 21, 2013 5:57:19 AM UTC+13, Benoit Thomas wrote:

        > no <C-D> :call SmoothScroll("\<C-E>")<CR>

        The ctrl-e is being interpreted as it would on the command line, see

        :help c_CTRL-E

        Any of V, Q, B, H, W, R, J, C may give the same kind of trouble, as will Y "When there is a modeless selection".

        I don't know why, but using "\x05" seems to avoid the problem for me, but I'm just echoing the argument to the function.

        You might consider

        no <expr> <C-D> SmoothScroll("\<C-E>")

        but that works differently; what the function returns is important.

        Regards, John Little

        --
        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
      • Ben Fritz
        ... Isn t it because the is being used as part of the mapping? Try C-E instead of just . -- You received this message from the vim_use
        Message 3 of 4 , Jan 20, 2013
        • 0 Attachment
          On Sunday, January 20, 2013 9:33:18 PM UTC-6, John Little wrote:
          > On Monday, January 21, 2013 5:57:19 AM UTC+13, Benoit Thomas wrote:
          >
          > > no <C-D> :call SmoothScroll("\<C-E>")<CR>
          >
          > The ctrl-e is being interpreted as it would on the command line, see
          >
          > :help c_CTRL-E
          >
          > Any of V, Q, B, H, W, R, J, C may give the same kind of trouble, as will Y "When there is a modeless selection".
          >
          > I don't know why, but using "\x05" seems to avoid the problem for me, but I'm just echoing the argument to the function.
          >
          > You might consider
          >
          > no <expr> <C-D> SmoothScroll("\<C-E>")
          >
          > but that works differently; what the function returns is important.
          >
          > Regards, John Little

          Isn't it because the <C-E> is being used as part of the mapping?

          Try \<LT>C-E> instead of just \<C-E>.

          --
          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
        • Benoit Thomas
          Thanks all for the explanation, I now better understand what happens under the hood. Using C-E did work. Ben. ... -- You received this message from the
          Message 4 of 4 , Jan 21, 2013
          • 0 Attachment
            Thanks all for the explanation, I now better understand what happens
            under the hood.

            Using \<LT>C-E> did work.

            Ben.

            On 20/01/2013 11:36 PM, Ben Fritz wrote:
            > On Sunday, January 20, 2013 9:33:18 PM UTC-6, John Little wrote:
            >> On Monday, January 21, 2013 5:57:19 AM UTC+13, Benoit Thomas wrote:
            >>
            >>> no <C-D> :call SmoothScroll("\<C-E>")<CR>
            >> The ctrl-e is being interpreted as it would on the command line, see
            >>
            >> :help c_CTRL-E
            >>
            >> Any of V, Q, B, H, W, R, J, C may give the same kind of trouble, as will Y "When there is a modeless selection".
            >>
            >> I don't know why, but using "\x05" seems to avoid the problem for me, but I'm just echoing the argument to the function.
            >>
            >> You might consider
            >>
            >> no <expr> <C-D> SmoothScroll("\<C-E>")
            >>
            >> but that works differently; what the function returns is important.
            >>
            >> Regards, John Little
            > Isn't it because the <C-E> is being used as part of the mapping?
            >
            > Try \<LT>C-E> instead of just \<C-E>.

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