469,271 Members | 852 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Vim scripting with python

Hi,

I saw several old posts speaking of vim scripting in Python. This one
in particular :
http://www.velocityreviews.com/forum...gt-vimpst.html

But I didn't find where to put this "vimrc.py" on my Windows machine.
My "normal" _vimrc file is in C:\Documents and Settings\my_name .

Does anyone have any advice, and more genraly how to script Vim with
Python ?

I know I can put some python functions inside my vimrc file like
this :

function! My_function()
python << EOF
import vim, string
....blablabla
EOF
endfunction

but I would like to use external ".py" files.

Thanks.

Feb 3 '07 #1
6 3765
On Sat, 03 Feb 2007 05:02:54 -0800, Tool69 wrote:
Does anyone have any advice, and more genraly how to script Vim with
Python ?
:py import sys
:py print sys.version
:help :py
I know I can put some python functions inside my vimrc file like
this :

function! My_function()
python << EOF
import vim, string
...blablabla
EOF
endfunction

but I would like to use external ".py" files.
:py import myfile

Use :py inside your vimrc - don't run python externally.
--
Stuart D. Gathman <st****@bmsi.com>
Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.

Feb 3 '07 #2
Thanks Stuart,
I'll take a look at it.

Another thing :
Is there any way to made some modification de the python.syntax file
to highlight the functions call, i.e :
os.popen(...) ---"popen(...)" will be highlighted.

Cheers.

Feb 4 '07 #3
Stuart D. Gathman wrote:
On Sat, 03 Feb 2007 05:02:54 -0800, Tool69 wrote:
>Does anyone have any advice, and more genraly how to script Vim with
Python ?

:py import sys
:py print sys.version
:help :py
>I know I can put some python functions inside my vimrc file like
this :

function! My_function()
python << EOF
import vim, string
...blablabla
EOF
endfunction

but I would like to use external ".py" files.

:py import myfile

Use :py inside your vimrc - don't run python externally.
Which versions of vim is this valid for? I tried ":py print 'Hello'",
and got "E319: Sorry, the command is not available in this version"

Cheers,
Cliff
Feb 12 '07 #4
On 2007-02-12, J. Clifford Dyer <we*******@cacradicalgrace.orgwrote:
Stuart D. Gathman wrote:
>On Sat, 03 Feb 2007 05:02:54 -0800, Tool69 wrote:
Use :py inside your vimrc - don't run python externally.

Which versions of vim is this valid for? I tried ":py print
'Hello'", and got "E319: Sorry, the command is not available in
this version"
The latest Windows build has the Python bindings included. The
one I have is version 7.0. Earlier Windows binaries didn't
generally have it.

--
Neil Cerutti
Feb 12 '07 #5
"J. Clifford Dyer" <we*******@cacradicalgrace.orgwrites:
Which versions of vim is this valid for? I tried ":py print 'Hello'",
and got "E319: Sorry, the command is not available in this version"
The ability of Vim to run Python commands is one of many optional
features that can be enabled or disabled when the program is
built. This allows a Vim program runtime of reasonable size (where
"reasonable" is decided by the person building the program); many of
the optional features are quite large, and building all of them into
the program would be a poor choice.

To find out what features are explicitly enabled or disabled in your
Vim program, type ':version'. The feature 'python' will be listed as
'+python' if enabled, '-python' if disabled.

If it's disabled and you want it enabled, you'll need to rebuild Vim
with that option enabled; or find someone who's done the same
(preferably the same person you got your default Vim from) and install
that program.

--
\ "If you continue running Windows, your system may become |
`\ unstable." -- Microsoft, Windows 95 BSOD message |
_o__) |
Ben Finney

Feb 13 '07 #6
J. Clifford Dyer wrote:
Stuart D. Gathman wrote:
On Sat, 03 Feb 2007 05:02:54 -0800, Tool69 wrote:
Does anyone have any advice, and more genraly how to script Vim with
Python ?
:py import sys
:py print sys.version
:help :py
I know I can put some python functions inside my vimrc file like
this :

function! My_function()
python << EOF
import vim, string
...blablabla
EOF
endfunction

but I would like to use external ".py" files.
:py import myfile

Use :py inside your vimrc - don't run python externally.

Which versions of vim is this valid for? I tried ":py print 'Hello'",
and got "E319: Sorry, the command is not available in this version"
It's valid for vim 5.0 and later (all official vim releases since
March 1998). You have to make sure python support is enabled at build
time with --enable-pythoninterp or other configure options that turn
it on (check for +python in the output of ":ver" to see if a
precompiled binary includes python support).

Feb 13 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by O'Neal Computer Programmer | last post: by
4 posts views Thread by The_Incubator | last post: by
41 posts views Thread by Richard James | last post: by
80 posts views Thread by Bibby | last post: by
6 posts views Thread by Wolfgang Keller | last post: by
15 posts views Thread by Birahim FALL | last post: by
4 posts views Thread by Julian | last post: by
8 posts views Thread by Nagarajan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.