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

weird, but logic: what to do?

Expand Messages
  • Kontra, Gergely
    Hi! I ve noticed some weirdness in vim scripting. Assume you have a map nma asdf :cal Fu() a and the fun: fu Fu() let n=input( What ) endf When I press
    Message 1 of 4 , Mar 12 6:56 AM
      Hi!

      I've noticed some weirdness in vim scripting.
      Assume you have a map
      nma asdf :cal Fu()<CR>a

      and the fun:

      fu Fu()
      let n=input('What')
      endf

      When I press asdf, The What prompt appears, and a is in the answer.
      Well, this is logical, but not desired :)

      How can I tell to input not eating characters?
      If I use inputdialog, and run gvim, it works fine...

      Gergo
      +-[Kontra, Gergely @ Budapest University of Technology and Economics]-+
      | Email: kgergely@..., kgergely@... |
      | URL: turul.eet.bme.hu/~kgergely Mobile: (+36 20) 356 9656 |
      +-------"Olyan langesz vagyok, hogy poroltoval kellene jarnom!"-------+
      .
      Magyar php mirror es magyar php dokumentacio: http://hu.php.net
    • Benji Fisher
      ... I think your best option is to use :startinsert like this nma asdf :cal Fu() fu Fu() let n=input( What ) if col( . ) == col( $ ) startinsert! else
      Message 2 of 4 , Mar 12 7:58 PM
        "Kontra, Gergely" wrote:
        >
        > Hi!
        >
        > I've noticed some weirdness in vim scripting.
        > Assume you have a map
        > nma asdf :cal Fu()<CR>a
        >
        > and the fun:
        >
        > fu Fu()
        > let n=input('What')
        > endf
        >
        > When I press asdf, The What prompt appears, and a is in the answer.
        > Well, this is logical, but not desired :)
        >
        > How can I tell to input not eating characters?
        > If I use inputdialog, and run gvim, it works fine...

        I think your best option is to use :startinsert like this

        nma asdf :cal Fu()<CR>

        fu Fu()
        let n=input('What')
        if col(".") == col("$")
        startinsert!
        else
        normal l
        startinsert
        endif
        endf

        Unfortunately, :startinsert acts like "i" and :startinsert! acts like "A" and
        you have to go to some trouble to make it act like "a".

        HTH --Benji Fisher
      • Kontra, Gergely
        ... Well, you re right here. But the question was wrong... You don t know what is it after the . (in my case it s true) Yes, I think, that scripting vim is
        Message 3 of 4 , Mar 13 8:50 AM
          >> nma asdf :cal Fu()<CR>a
          >> fu Fu()
          >> let n=input('What')
          >> endf
          >
          > I think your best option is to use :startinsert like this

          Well, you're right here.
          But the question was wrong...

          You don't know what is it after the <CR>.
          (in my case it's true)

          Yes, I think, that scripting vim is DIFFICULT, so Bram should do
          something...

          Gergo
          +-[Kontra, Gergely @ Budapest University of Technology and Economics]-+
          | Email: kgergely@..., kgergely@... |
          | URL: turul.eet.bme.hu/~kgergely Mobile: (+36 20) 356 9656 |
          +-------"Olyan langesz vagyok, hogy poroltoval kellene jarnom!"-------+
          .
          Magyar php mirror es magyar php dokumentacio: http://hu.php.net
        • mailings
          Hi, ... and ... Another option might be to use (evaluate Fu() by pasting the expression-Register; however any return-values of Fu() are executed in
          Message 4 of 4 , Mar 14 2:05 AM
            Hi,

            > > I've noticed some weirdness in vim scripting.
            > > Assume you have a map
            > > nma asdf :cal Fu()<CR>a
            > >
            > > and the fun:
            > >
            > > fu Fu()
            > > let n=input('What')
            > > endf
            > >
            > > When I press asdf, The What prompt appears, and a is in the answer.
            > > Well, this is logical, but not desired :)
            > >
            > > How can I tell to input not eating characters?
            > > If I use inputdialog, and run gvim, it works fine...
            >
            > I think your best option is to use :startinsert like this
            >
            > nma asdf :cal Fu()<CR>
            >
            > fu Fu()
            > let n=input('What')
            > if col(".") == col("$")
            > startinsert!
            > else
            > normal l
            > startinsert
            > endif
            > endf
            >
            > Unfortunately, :startinsert acts like "i" and :startinsert! acts like "A"
            and
            > you have to go to some trouble to make it act like "a".

            Another option might be to use (evaluate Fu() by pasting the
            expression-Register; however any return-values of Fu() are executed in
            insert-mode):

            nmap asdf a<C-R>=Fu()<CR>

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