I am making the distinction between using :w and not.  Rarely would you
not want to save, but I can understand that there would be situations
otherwise.

Chuck

-----Original Message-----
From: A.J.Mechelynck [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 24, 2006 9:57 AM
To: Chuck Mason
Cc: Carroll, Barry; [email protected]
Subject: Re: Python Script Execution Support in ViM

Chuck Mason wrote:
> Try this the function below.  I'm a very novice vim programmer so
> forgive me if there's an easier way to do this.  However, what's below
> seemed to work for me.  
> 
> Chuck
> 
> 
> 
> 
> function! ExecuteCurBufAsPython()
>       let buffer = getline(1, line("$"))
>       let newbuf = ""
>       let index = 0
>       while index < len(buffer)
>               let line = buffer[index]
>               let newbuf = newbuf . "\n" . line
>               let index = index + 1
>       endwhile
>       execute "python " . newbuf
> endfunc
> 
> :nmap <F5> :call ExecuteCurBufAsPython()

To pass the current buffer (which must have a valid filename) to the 
Python interpreter and run it as a Python script:

        :w
        :pyfile %

or
        :map    <F5>    w<Bar>pyfile %

If ":pyfile %" doesn't work (I think it will), then use

        :exec "pyfile" expand("%")

instead.


Best regards,
Tony.

Reply via email to