Tony,

You are right.

Now, one vimrc works on Windows and unix with mixture of version 6, version 7.

Based on your suggestion, I have replaced "for" loop with "while" loop, and it worked!


PS: script

   " for sug in s:suglist
   "   exe 'amenu 1.5.'.pri.' PopUp.'.s:changeitem.'.'.escape(sug, ' .')
   "         \ . ' :call <SID>SpellReplace(' . pri . ')<CR>'
   "   let pri += 1
   " endfor

     while(j>0)
       let sug=s:suglist[j]
       exe 'amenu 1.5.'.pri.' PopUp.'.s:changeitem.'.'.escape(sug, ' .')
             \ . ' :call <SID>SpellReplace(' . pri . ')<CR>'
       let pri += 1
       let j -= 1
     endwhile




From: "A.J.Mechelynck" <[EMAIL PROTECTED]>
To: Xiangjiang Ma <[EMAIL PROTECTED]>
CC: [EMAIL PROTECTED], [email protected]
Subject: Re: gvimrc vs vimrc
Date: Tue, 30 May 2006 03:26:30 +0200

Xiangjiang Ma wrote:


   if has("gui_running")
      " any code here affects gvim but not console vim
   else
      " any code here affects console vim but not gvim
   endif


One problem I found is that console vim (using cygwin) will complain if I have "for" statement inside anywhere in vimrc, as (taken from sample spell script)

       for sug in s:suglist
exe 'amenu 1.5.'.pri.' PopUp.'.s:changeitem.'.'.escape(sug, ' .')
               \ . ' :call <SID>SpellReplace(' . pri . ')<CR>'
         let pri += 1
       endfor




It's not because it's console Vim, it is (I think) because your console Vim is an earlier version (the :for construct is new in Vim 7). In some cases you can replace a ":for" loop by a ":while" loop; in others you have to bracket version-7-only code by means of ":if version >= 700" ... "endif". IIUC, version-6 Vim sometimes even mistakes "endfor" with "endfunction" which is IMHO a bug but unlikely to be fixed in version 6. In such cases it may take some fancy footwork to make sure that Vim executables of version 6 (or earlier) will never even source the for...endfor construct. Unless of course you make sure to use only verson 7 (or later): for instance, by starting a script (or even your vimrc) with

   if version < 700
      echoerr "Please use Vim version 7 or higher"
      finish
   endif


Best regards,
Tony.


Reply via email to