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

Re: Problems with multi-line commands

Expand Messages
  • Benji Fisher
    ... The problem is that compatible is set (so that vim is more vi-compatible) when your plugins are loaded. Like traditional vi, vim will then recognize
    Message 1 of 5 , Feb 1, 2006
    • 0 Attachment
      On Wed, Feb 01, 2006 at 11:14:45AM +0100, Gregor Berginc wrote:
      > Dear all,
      >
      > I am experiencing interesting problem with custom plugins. Suppose you
      > have a function:
      >
      > function! Hello(text)
      > echo "Hello "
      > \. a:text
      > endfunction
      >
      > If I put this function in my ~/.gvimrc and call it, I get the correct
      > result. But, if I put it in a plugin directory, e.g.,
      > ~/.vim/plugin/test.vim, I get the following error:
      >
      > Error detected while processing function Hello:
      > line 2:
      > E10: \ should be followed by /, ? or &
      >
      > Therefore, the backslash is causing problems. Is there any reasonable
      > answer to this problem?
      >
      > Thanks in advance for your replies.

      The problem is that 'compatible' is set (so that vim is more
      vi-compatible) when your plugins are loaded. Like traditional vi, vim
      will then recognize your continuation line as an error. By the time vim
      gets to your gvimrc file, 'nocompatible' is set.

      Let me see: according to ":help startup" the sequence is (skipping
      several steps)

      3c. Read your vimrc file.
      4. Load the plugin scripts.
      8. Perform GUI initializations (including your gvimrc file).

      If vim finds a vimrc file (exrc does not count) in Step 3, then it
      automatically sets 'nocompatible' and the problem will go away.

      HTH --Benji Fisher
    • Gregor Berginc
      Thanks Benji. I thought that gvim always consults both .vimrc and .gvimrc. Best, Gregor ... -- Gregor Berginc, Ph.D. Student University of Ljubljana, Faculty
      Message 2 of 5 , Feb 1, 2006
      • 0 Attachment
        Thanks Benji. I thought that gvim always consults both .vimrc and .gvimrc.

        Best,
        Gregor

        On 2/1/06, Benji Fisher <benji@...> wrote:
        > On Wed, Feb 01, 2006 at 11:14:45AM +0100, Gregor Berginc wrote:
        > > Dear all,
        > >
        > > I am experiencing interesting problem with custom plugins. Suppose you
        > > have a function:
        > >
        > > function! Hello(text)
        > > echo "Hello "
        > > \. a:text
        > > endfunction
        > >
        > > If I put this function in my ~/.gvimrc and call it, I get the correct
        > > result. But, if I put it in a plugin directory, e.g.,
        > > ~/.vim/plugin/test.vim, I get the following error:
        > >
        > > Error detected while processing function Hello:
        > > line 2:
        > > E10: \ should be followed by /, ? or &
        > >
        > > Therefore, the backslash is causing problems. Is there any reasonable
        > > answer to this problem?
        > >
        > > Thanks in advance for your replies.
        >
        > The problem is that 'compatible' is set (so that vim is more
        > vi-compatible) when your plugins are loaded. Like traditional vi, vim
        > will then recognize your continuation line as an error. By the time vim
        > gets to your gvimrc file, 'nocompatible' is set.
        >
        > Let me see: according to ":help startup" the sequence is (skipping
        > several steps)
        >
        > 3c. Read your vimrc file.
        > 4. Load the plugin scripts.
        > 8. Perform GUI initializations (including your gvimrc file).
        >
        > If vim finds a vimrc file (exrc does not count) in Step 3, then it
        > automatically sets 'nocompatible' and the problem will go away.
        >
        > HTH --Benji Fisher
        >


        --
        Gregor Berginc, Ph.D. Student
        University of Ljubljana, Faculty of CIS
        Trzaska 25, SI-1001 Ljubljana, Slovenia
        tel: +386 1 4776630, fax: +386 1 4264647
        www: http://vicos.fri.uni-lj.si/gregor
      • Hari Krishna Dara
        ... Actually, it is recommended that plugins that use the line-continuation characters explicitly modify cpo to make sure they work in all environments. You
        Message 3 of 5 , Feb 1, 2006
        • 0 Attachment
          On Wed, 1 Feb 2006 at 8:18am, Benji Fisher wrote:

          > On Wed, Feb 01, 2006 at 11:14:45AM +0100, Gregor Berginc wrote:
          > > Dear all,
          > >
          > > I am experiencing interesting problem with custom plugins. Suppose you
          > > have a function:
          > >
          > > function! Hello(text)
          > > echo "Hello "
          > > \. a:text
          > > endfunction
          > >
          > > If I put this function in my ~/.gvimrc and call it, I get the correct
          > > result. But, if I put it in a plugin directory, e.g.,
          > > ~/.vim/plugin/test.vim, I get the following error:
          > >
          > > Error detected while processing function Hello:
          > > line 2:
          > > E10: \ should be followed by /, ? or &
          > >
          > > Therefore, the backslash is causing problems. Is there any reasonable
          > > answer to this problem?
          > >
          > > Thanks in advance for your replies.
          >
          > The problem is that 'compatible' is set (so that vim is more
          > vi-compatible) when your plugins are loaded. Like traditional vi, vim
          > will then recognize your continuation line as an error. By the time vim
          > gets to your gvimrc file, 'nocompatible' is set.
          >
          > Let me see: according to ":help startup" the sequence is (skipping
          > several steps)
          >
          > 3c. Read your vimrc file.
          > 4. Load the plugin scripts.
          > 8. Perform GUI initializations (including your gvimrc file).
          >
          > If vim finds a vimrc file (exrc does not count) in Step 3, then it
          > automatically sets 'nocompatible' and the problem will go away.
          >
          > HTH --Benji Fisher
          >
          >

          Actually, it is recommended that plugins that use the line-continuation
          characters explicitly modify 'cpo' to make sure they work in all
          environments. You should contact the author to make this change or do
          this change yourself in your local copy. Typically, you would add the
          below at the start:

          " Make sure line-continuations won't cause any problem. This will be restored
          " at the end
          let s:save_cpo = &cpo
          set cpo&vim

          and the below at the end of the plugin file:

          " Restore cpo.
          let &cpo = s:save_cpo
          unlet s:save_cpo

          --
          HTH,
          Hari

          __________________________________________________
          Do You Yahoo!?
          Tired of spam? Yahoo! Mail has the best spam protection around
          http://mail.yahoo.com
        • Benji Fisher
          ... Yes, gvim reads both. Do you have a vimrc file? If not, then the special rule about setting nocompatible does not apply. Since the plugins are read
          Message 4 of 5 , Feb 1, 2006
          • 0 Attachment
            On Wed, Feb 01, 2006 at 10:33:05AM -0800, Gregor Berginc wrote:
            >
            > On 2/1/06, Benji Fisher <benji@...> wrote:
            > >
            > > The problem is that 'compatible' is set (so that vim is more
            > > vi-compatible) when your plugins are loaded. Like traditional vi, vim
            > > will then recognize your continuation line as an error. By the time vim
            > > gets to your gvimrc file, 'nocompatible' is set.
            > >
            > > Let me see: according to ":help startup" the sequence is (skipping
            > > several steps)
            > >
            > > 3c. Read your vimrc file.
            > > 4. Load the plugin scripts.
            > > 8. Perform GUI initializations (including your gvimrc file).
            > >
            > > If vim finds a vimrc file (exrc does not count) in Step 3, then it
            > > automatically sets 'nocompatible' and the problem will go away.
            >
            > Thanks Benji. I thought that gvim always consults both .vimrc and .gvimrc.

            Yes, gvim reads both. Do you have a vimrc file? If not, then the
            special rule about setting 'nocompatible' does not apply. Since the
            plugins are read before your gvimrc file, they will be read with
            'compatible' set, no matter what you have in your gvimrc file nor
            whether you even have one.

            HTH --Benji Fisher
          Your message has been successfully submitted and would be delivered to recipients shortly.