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

Map calls two functions - aware of insertmode

Expand Messages
  • David Fishburn
    Vim 7.1.229 WinXP Not having much luck with this, looking for suggestions. I have a function that is called via an omap. Once the function completes, I want to
    Message 1 of 2 , Jan 31, 2008
    • 0 Attachment
      Vim 7.1.229 WinXP

      Not having much luck with this, looking for suggestions.

      I have a function that is called via an omap.
      Once the function completes, I want to call another function.
      But if the first function puts me in insertmode, then my attempts to
      call the second function ends up be entered as text in insert mode.
      To get around this, I have tried using <C-\><C-O>, but so far can't
      get it right.

      Tried various options:
      exec 'onoremap <silent> '.o_map."
      :<C-U>MyOMap'".o_map."'<CR>\|:call MySecondFcn()<CR>"
      exec 'onoremap <silent> '.o_map."
      :<C-U>MyOMap'".o_map."'<CR>\|<C-\><C-O>:call MySecondFcn()<CR>"
      exec 'onoremap <silent> '.o_map."
      :<C-U>MyOMap'".o_map."'<CR><Bar><C-\><C-O>:call MySecondFcn()<CR>"

      Thanks for any help.
      Dave

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Ben Schmidt
      ... Why do you need the bar? And won t you need to escape the backslash in the on account of the double quotes? And it looks like MyOMap was a command in
      Message 2 of 2 , Jan 31, 2008
      • 0 Attachment
        > Tried various options:
        > exec 'onoremap <silent> '.o_map."
        > :<C-U>MyOMap'".o_map."'<CR>\|:call MySecondFcn()<CR>"
        > exec 'onoremap <silent> '.o_map."
        > :<C-U>MyOMap'".o_map."'<CR>\|<C-\><C-O>:call MySecondFcn()<CR>"
        > exec 'onoremap <silent> '.o_map."
        > :<C-U>MyOMap'".o_map."'<CR><Bar><C-\><C-O>:call MySecondFcn()<CR>"

        Why do you need the bar?

        And won't you need to escape the backslash in the <C-\> on account of the double
        quotes?

        And it looks like MyOMap was a command in the above, not a function, as you have
        no :call and no brackets around its argument? Shouldn't you either omit the quotes
        around the argument to MyOMap (if it's a command) or put brackets and :call?

        So, linewrapped for ease of reading, I would think you want either

        exec 'onoremap <silent> '.
        o_map.
        ":<C-U>MyOMap'".
        o_map.
        "'<CR><C-\\><C-O>:call MySecondFcn()<CR>"

        or

        exec 'onoremap <silent> '.
        o_map.
        ":<C-U>call MyOMap('".
        o_map.
        "')<CR><C-\\><C-O>:call MySecondFcn()<CR>"

        Ben.





        Send instant messages to your online friends http://au.messenger.yahoo.com


        --~--~---------~--~----~------------~-------~--~----~
        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.