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

Re: How do I prompt & substitute during expansion of a stub?

Expand Messages
  • Luc Hermitte
    ... Check {}/after/templates/template.vim ... OK. ... I was refering to what I use in my ftplugins: fun! s:ExpandMyStuff() if doit(......) return
    Message 1 of 4 , Jan 6, 2005
    • 0 Attachment
      * On Thu, Jan 06, 2005 at 03:52:31PM -0800, Keith Roberts <kroberts@...> wrote:
      > >I know it is not exactly what you are looking for, but you can
      > >have a look at my declinaison of mu-template [1]. It permits
      > >quite easily to call any function (input()/inputdialog() in
      > >your case) during the expansion of the template file, or just
      > >leave a placeholder (/marker) where you could jump to at a
      > >later time -- this later approach will enable you to use the
      > >automatic completion.
      >
      > I got nothing directly pertinent from the above. That doesn't nean it
      > isn't there, just that I didn't get anything from it. :)

      Check {}/after/templates/template.vim

      > >May be:
      > > let cmd = ".....".input('first xxxx').'ITEM'.input('2nd
      > >xxxx'). ....
      > This won't work, because the input() is executed when 'cmd' is defined
      > (at startup), not when the stub is activated.

      OK.


      > >Another approach is to use <c-r>= and return an expression to
      >
      > If you look at the code snippet, this is the approach I was attempting
      > to use, only ^R^R= instead of ^R= ... Also, the code snippet I included
      > wasn't the best one I had; this is better:


      I was refering to what I use in my ftplugins:

      fun! s:ExpandMyStuff()
      if doit(......)
      return "\<esc>viwsERRMSG=UF.READU("
      \ ."\<c-r>=inputdialog(\"xxx:\")\<cr>"
      \ .")zzz"

      " BTW: prefer ``viws'' (or better: ``viw"_s'') over ``bcw''
      " Just try to expand a letter to see the difference

      " I do not know why, input() does not behave correctly
      else ....
      endf

      inoremap <silent> <buffer> ² <c-r>=<sid>ExpandMyStuff()<cr>

      --
      Luc Hermitte
      http://hermitte.free.fr/vim/
    Your message has been successfully submitted and would be delivered to recipients shortly.