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

Re: omap with 'f' and 't' and getchar() and nr2char()

Expand Messages
  • Ben Schmidt
    ... The :call MyDisplay() should either be part of the expression that MyExprOp returns, or appended to it with the . operator. So far you ve tried
    Message 1 of 18 , May 31, 2008
    • 0 Attachment
      > I am happy to use expression maps if I can somehow get a function to
      > be called after them using the technique (or otherwise) above:
      > onoremap <expr> f MyExprOp('f')<bar>:call MyDisplay()<CR>
      >
      > Just wondering if there is anyway how this might be accomplished.

      The ":call MyDisplay()<CR>" should either be part of the expression that MyExprOp
      returns, or appended to it with the "." operator. So far you've tried including it
      as for a regular map, not an <expr> map. Try (roughly)

      func! MyExprOp(arg)
      let char=getchar()
      return "f".char.":call MyDisplay()\<CR>"
      endfunc

      or

      onoremap <expr> f MyExprOp('f').":call MyDisplay()\<CR>"

      and let me know how you go...

      Ben.



      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • David Fishburn
      ... YES! That works like a charm and it makes sense too! --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use
      Message 2 of 18 , Jun 2, 2008
      • 0 Attachment
        ...
        > The ":call MyDisplay()<CR>" should either be part of the expression that MyExprOp
        > returns, or appended to it with the "." operator. So far you've tried including it
        > as for a regular map, not an <expr> map. Try (roughly)
        >
        > func! MyExprOp(arg)
        > let char=getchar()
        > return "f".char.":call MyDisplay()\<CR>"
        > endfunc
        >
        > or
        >
        > onoremap <expr> f MyExprOp('f').":call MyDisplay()\<CR>"

        YES!

        That works like a charm and it makes sense too!

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      Your message has been successfully submitted and would be delivered to recipients shortly.