On Sep 20, 7:33 pm, Hari Krishna Dara <[email protected]> wrote:
> On Sat, Sep 19, 2009 at 9:15 PM, Peng Yu <[email protected]> wrote:
>
>
>
> > Hi,
>
> > Suppose I am editing a python file (which is executable), I then type
> > ":!python_file_name.py" to run it. I would like vim help me position
> > the cursor to the error line if there is a syntax error in the python
> > file.
>
> > Is there a way to do it?
>
> See this blog:http://www.sontek.net/post/Python-with-a-modular-IDE-(Vim).aspx
As instructed by the above webpage, I put the following code to
my .vimrc
python << EOL
import vim
def EvaluateCurrentRange():
eval(compile('\n'.join(vim.current.range),'','exec'),globals())
EOL
map <C-h> :py EvaluateCurrentRange()
But I get the following error when I open an .py file. What's wrong
with it?
$ gvim main.py
Error detected while processing /home/pengy/.vimrc:
line 93:
E319: Sorry, the command is not available in this version: python <<
EOL
line 94:
E492: Not an editor command: import vim
line 95:
E492: Not an editor command: def EvaluateCurrentRange():
line 96:
E492: Not an editor command: eval(compile('\n'.join
(vim.current.range),'','exec'),globals())
line 97:
E492: Not an editor command: EOL
> I an ftplugin/python_makeprg.vim with this contents:
>
> ----------------
> if has('win32')
> set makeprg=python\ -c\ \"\"import\ py_compile,sys;\
> sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"\"
> else
> set makeprg=python\ -c\ \"import\ py_compile,sys;\
> sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
> endif
> set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]...@=%m
>
> python << EOL
> import vim
> def EvaluateCurrentRange():
> eval(compile('\n'.join(vim.current.range),'','exec'),globals())
> EOL
> " Evaluate the selected range.
> vnoremap <buffer> <silent> <Leader>ev :py EvaluateCurrentRange()<CR>
> ------------
>
> But honestly, I never used this myself so far, kind of forgot that I
> even had it.
>
> --
> HTH,
> Hari
>
> > Regards,
> > Peng
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---