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

input() inside mapping eats rest of mapping

Expand Messages
  • Yakov Lerner
    I tried to use input() inside mapping and got unexpected results. ... , then press ;; Unexpectedly, I don t get prompt Enter something . Instead, input()
    Message 1 of 3 , Mar 1 4:09 AM
    • 0 Attachment
      I tried to use input() inside mapping and got unexpected results.
      Let's say I execute the following line:

      :map ;; :let c=input("Enter something ")<cr>iabc<esc>:echo "--> c=".c<cr>

      , then press ;;

      Unexpectedly, I don't get prompt "Enter something ". Instead,
      input() seems to be fed with what follows in mapping. Command 'iabc<esc'
      is not executed. Is it how it is supposed to be ?

      Yakov
    • Benji Fisher
      ... Yes. See the TWIN() function in foo.vim for an example of how to use a mapping and a function for this sort of thing.
      Message 2 of 3 , Mar 1 7:31 AM
      • 0 Attachment
        On Mon, Mar 01, 2004 at 02:09:50PM +0200, Yakov Lerner wrote:
        > I tried to use input() inside mapping and got unexpected results.
        > Let's say I execute the following line:
        >
        > :map ;; :let c=input("Enter something ")<cr>iabc<esc>:echo "--> c=".c<cr>
        >
        > , then press ;;
        >
        > Unexpectedly, I don't get prompt "Enter something ". Instead,
        > input() seems to be fed with what follows in mapping. Command 'iabc<esc'
        > is not executed. Is it how it is supposed to be ?
        >
        > Yakov

        Yes. See the TWIN() function in foo.vim for an example of how to
        use a mapping and a function for this sort of thing.

        http://www.vim.org/script.php?script_id=72

        HTH --Benji Fisher
      • Antony Scriven
        ... Antony
        Message 3 of 3 , Mar 1 5:06 PM
        • 0 Attachment
          Yakov Lerner wrote:

          > I tried to use input() inside mapping and got unexpected results.
          > Let's say I execute the following line:
          >
          > :map ;; :let c=input("Enter something ")<cr>iabc<esc>:echo "--> c=".c<cr>
          >
          > , then press ;;
          >
          > Unexpectedly, I don't get prompt "Enter something ". Instead,
          > input() seems to be fed with what follows in mapping. Command 'iabc<esc'
          > is not executed. Is it how it is supposed to be ?

          :help inputsave()
          :help inputrestore()

          Antony
        Your message has been successfully submitted and would be delivered to recipients shortly.