473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

vim & python

sb
Hello

I have a bunch of questions about using python scripting in vim and
about editing python with vim.
I can install vim with python scripting support, but I can not find
docs, examples or tutorials about scripting vim using python anywhere
with google.
Is it possible to enable "calltips" while editing python documents
with vim? (BTW I've read somewhere that pyalamode was created
specifically because someone wanted "calltips" not just in the
interpreter, but in the editor as well. FWIW, VC++ has had calltips
for many years. However, I can not get those calltips to work in
pyalamode either. So I'm anxious to find any editor for python that
has calltips, but I would prefer it to be vim though)
I've heard the biggest python gurus use vim. *Please* post some
screenshots of you in action - some interesting things like
- calltips,
- editor-shell interaction
- reference manual invocation by keyword from within the editor
- object browser,
- etc.
Or are you using vim just like C coders do?
Jul 18 '05 #1
16 3839
sb wrote:
Is it possible to enable "calltips" while editing python documents
with vim?
I don't think so.
I've heard the biggest python gurus use vim. *Please* post some
screenshots of you in action - some interesting things like
- calltips,
- editor-shell interaction
- reference manual invocation by keyword from within the editor
- object browser,
- etc.
Or are you using vim just like C coders do?


I'm using it 'like C coders', if that means that I do happily use syntax
highlighting, auto-indentation and line-numbering, but not anything
else.

Note that I'm not one of the biggest python gurus ;-)

Gerrit.

--
Weather in Twenthe, Netherlands 01/03 20:25 UTC:
3.0°C wind 3.6 m/s W (57 m above NAP)
--
Asperger's Syndrome - a personal approach:
http://people.nl.linux.org/~gerrit/english/

Jul 18 '05 #2
sb <sp**********@yahoo.com> wrote:
I've heard the biggest python gurus use vim. *Please* post some
screenshots of you in action - some interesting things like
- calltips,
- editor-shell interaction
- reference manual invocation by keyword from within the editor
- object browser,
- etc.
Or are you using vim just like C coders do?


While definitely not being a guru I use vims Syntax highlighting
plus these settings for all files ending in .py:

highlight Comment ctermfg=white

set smartindent
cinwords=if,elif,else,for,while,try,except,finally ,def,class
set tabstop=4
set shiftwidth=4
set smarttab
set expandtab
set softtabstop=4
set autoindent

Depending on your style of coding you might want to tune them,
but they're pointers. They most probably have room for
improvement, too.

As for calltips, shell interaction and all the othe nifty stuff:
I don't use it. And while they sometimes sound cool I always
ended up being more annoyed than helped by them.

Greets,
Tobias

--
Thank you for calling $PROVIDER helpdesk. If your cupholder is
broken, please press 1. If you want an actual knowledgable support
person, please enter the IP representation of a /28 netmask."
Jul 18 '05 #3
Look at taglist.vim (links below), a popular souce-browsing Vim
script. It's the only major script I'm using right now. I don't know
of any definitive Python calltips available for Vim (I assume they
would be difficult with flexible parameters and return values), but
taglist.vim provides function prototypes in the form of parameter
lists (search for 'prototype' in the taglist docs).

I've tried a few nifty Python-specific scripts (search www.vim.org)
but always wound up forgetting the special commands and resorting to
Vim staples. For example, the following two lines in my .vimrc were
good enough to condense all the functions and classes in a file:

set foldmethod=indent
set foldnestmax=2

My .vimrc also includes this "execute code and output results in new
buffer" script (which should all be on one line):

map <F4> :w<CR>:let @a = system('`which python` ' .
bufname('%'))<CR>:silent botright new output<CR>:silent normal "aP<CR>

Normally I use GVim next to a terminal window tabbed with IPython
(ipython.scipy.org/) and a browser tabbed with whatever documentation
I may need - Python docs, RFCs, and project docs
(epydoc.sourceforge.net/). IPython helps access the nitty-gritty
aspects of Python, Epydoc allows me to browse documentation and
package structures elegantly. And though I am by no means a Python
guru, I've posted a screenshot of my "modular IDE" in action (link
below).

I went through a do-it-all-in-Vim stage and left feeling as though I
had just spent too much time playing with my tool. Keeping a browser
and terminal open all the time anyway, I eventually dismissed the
all-in-one paradigm as some quixotic jab at Emacs.

Happy vimmings,
poiboy

taglist.vim
http://www.vim.org/scripts/script.php?script_id=273

exuberant ctags
http://ctags.sourceforge.net/

screenshot
http://aonalu.makahavalley.org/img/g...nq_ipython.png (197K,
1600x1200)
Check out the function prototype on the bottom of GVim's window.
Jul 18 '05 #4
On 1 Mar 2004 17:48:17 -0800, poiboy <bi*******@safe-mail.net> wrote:
Look at taglist.vim (links below), a popular souce-browsing Vim
script. It's the only major script I'm using right now. I don't know
of any definitive Python calltips available for Vim (I assume they
would be difficult with flexible parameters and return values), but
taglist.vim provides function prototypes in the form of parameter
lists (search for 'prototype' in the taglist docs).

I've tried a few nifty Python-specific scripts (search www.vim.org)
but always wound up forgetting the special commands and resorting to
Vim staples. For example, the following two lines in my .vimrc were
good enough to condense all the functions and classes in a file:

set foldmethod=indent
set foldnestmax=2

My .vimrc also includes this "execute code and output results in new
buffer" script (which should all be on one line):

map <F4> :w<CR>:let @a = system('`which python` ' .
bufname('%'))<CR>:silent botright new output<CR>:silent normal "aP<CR>

Normally I use GVim next to a terminal window tabbed with IPython
(ipython.scipy.org/) and a browser tabbed with whatever documentation
I may need - Python docs, RFCs, and project docs
(epydoc.sourceforge.net/). IPython helps access the nitty-gritty
aspects of Python, Epydoc allows me to browse documentation and
package structures elegantly. And though I am by no means a Python
guru, I've posted a screenshot of my "modular IDE" in action (link
below).

I went through a do-it-all-in-Vim stage and left feeling as though I
had just spent too much time playing with my tool. Keeping a browser
and terminal open all the time anyway, I eventually dismissed the
all-in-one paradigm as some quixotic jab at Emacs.

Happy vimmings,
poiboy

taglist.vim
http://www.vim.org/scripts/script.php?script_id=273

exuberant ctags
http://ctags.sourceforge.net/

screenshot
http://aonalu.makahavalley.org/img/g...nq_ipython.png (197K,
1600x1200)
Check out the function prototype on the bottom of GVim's window.


very nice.
--
Ashot Petrosian
University of Texas at Austin, Computer Science
Jul 18 '05 #5
Not sure what you mean exactly, but this may do it:

http://members.nccw.net/kdahlhaus/py...n.html#pyhints
Is it possible to enable "calltips" while editing python documents
with vim?

Jul 18 '05 #6
On Tue, 2004-03-02 at 02:48, poiboy wrote:
Normally I use GVim next to ....


i always wanted to ask this...
why people use GVIm and not the normal-vim-in-a-terminal?

what is the advantage of gvim?

thanks,
gabor
Jul 18 '05 #7
[gabor]
i always wanted to ask this... why people use GVIm and not the
normal-vim-in-a-terminal? what is the advantage of gvim?


Mainly the ability to use the mouse for some quick operations, like
positioning the cursor between two characters, moving big distances by
dragging scroll bars, changing window dimensions by dragging the bars
between windows, wandering in help through clicking on index items,
clicking within the fold margin for opening and closing folds, etc.

I'm usually not fond on the mouse, but strangely (to me at least),
`gvim' is effectively taming me into using it. One thing which I often
do is repeating mouse fast positioning of the cursor with `.' typed with
the left hand. It is also surprising how many `vim' operations you can
quickly do with the left hand alone! :-)

One thing which helped me a lot is that, right from the beginning, I
took the time of carefully customising `gvim' so it uses readable fonts,
consistent colours, and such things. As for Python editing, of course,
`vim' customisation is equally available within and outside X.

--
François Pinard http://www.iro.umontreal.ca/~pinard

Jul 18 '05 #8
gabor wrote:
On Tue, 2004-03-02 at 02:48, poiboy wrote:
Normally I use GVim next to ....

i always wanted to ask this...
why people use GVIm and not the normal-vim-in-a-terminal?

what is the advantage of gvim?

thanks,
gabor


So when you need to use a command that you don't use frequently you
don't have to dig through docs somewhere, you can just find it in the
menus. Or, if you work in windows it's more natural.

Jul 18 '05 #9
> what is the advantage of gvim?

I switched to GVim after moving from desktop/mouse to
laptop/trackpoint because trackpointers (a must-have, little knobby
joystick in the middle of the keyboard) eliminate the expense of small
pointer movements (if any IBM reps are reading, I am your ThinkPad
cheerleader). On the desktop, I felt most comfortable leaving the
mouse alone and using 'screen'
(http://www.gnu.org/software/screen/screen.html) to organize multiple
Vim windows.

In addition to the benefits already mentioned, GVim maintained better
speed than Vim after I added:

autocmd BufEnter * :syntax sync fromstart

to alleviate (brutally) highlighting consistency problems with larger
files (500+ lines or so).

Aloha,
the poiboy
Jul 18 '05 #10
On Mon, 01 Mar 2004 11:51:24 -0800, sb wrote:
Hello

I have a bunch of questions about using python scripting in vim and about
editing python with vim.


I'm very happy with word completion.

From ":help ins-complet":

For example, the following will map <Tab> to either actually insert a <Tab> if
the current line is currently only whitespace, or start/continue a CTRL-N
completion operation: >

function! CleverTab()
if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
return "\<Tab>"
else
return "\<C-N>"
endfunction
inoremap <Tab> <C-R>=CleverTab()<CR>

I found out about this wrt "pydiction" which parses python files
and outputs a diction file with words for vim to complete on. However,
I don't use it, as it pollutes the completion namespace too much.

Simon.

Jul 18 '05 #11
On Tue, 02 Mar 2004 16:02:19 +0100, gabor <ga***@z10n.net> wrote:
i always wanted to ask this...
why people use GVIm and not the normal-vim-in-a-terminal?


Mouse support
marking regions,
resizing windows,
Pinnable menus
The toolbar
Better colour choices.
Better integration with Windoze(clipboard etc)
Bigger windows (but an xterm fixes that...)

Those are my main reasons.

Alan G.
Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld
Jul 18 '05 #12
sb wrote:
Hello
Hi!
- reference manual invocation by keyword from within the editor
Please try my pydoc.vim, it is available at:

http://www.vim.org/scripts/script.php?script_id=910
- object browser,


Use taglist.vim, it is great!

André
Jul 18 '05 #13
In article <c2*************@ID-112871.news.uni-berlin.de>,
André Kelpe <fs***@linuxmail.org> wrote:
sb wrote:
Hello


Hi!
- reference manual invocation by keyword from within the editor


Please try my pydoc.vim, it is available at:

http://www.vim.org/scripts/script.php?script_id=910
- object browser,


Use taglist.vim, it is great!

André


Thanks Andre, that looks great!

Now if I could only get vim to highlight paren/bracket/curly-bracket
completion as it does when editing shell scripts!

-frank
--
Jul 18 '05 #14
fp*@u.washington.edu (Frank Miles) wrote in news:c24vco$9ro$1
@nntp6.u.washington.edu:

Now if I could only get vim to highlight paren/bracket/curly-bracket
completion as it does when editing shell scripts!


try
:set showmatch
or
:set sm

Scott
Jul 18 '05 #15
> > I have a bunch of questions about using python scripting in vim and
about editing python with vim.


Thanks for all of the answers to the second question, but what about
vim scripting with python? I can not find *anything* about it (no
docs, books or tutorials)


I don't have a tutorial, but I've written a quite large python script for
vim called vimsh. It might be helpful for you as a reference:

http://vim.sourceforge.net/scripts/s...?script_id=165

hth,
~brian

--
..--------------------------------------------------,--------.
| Brian Sturk - http://users.adelphia.net/~bsturk \ C/C++ |
|-------------------------. bsturk<AT>adelphia.net | Python |
| http://www.telengard.com `------------------------`-------|
| Telengard Technologies Inc. - NT/*nix UI & device drivers |
`-----------------------------------------------------------'
Jul 18 '05 #16
On 4 Mar 2004 18:53:18 -0800, sb <sp**********@yahoo.com> wrote:
Thanks, but that is more like a very abbreviated tutorial. Where can I
can the real documentation? It seems like the python built into vim is
different. For example, doing

:py import sys
:py dir(sys)

produces no output. Odd.


The statement 'dir(sys)' doesn't produce any output in Python. What's
confusing you is that the interactive mode of the python interpreter
prints the values of expression statements, if the value is not None.
That's a feature of the interactive mode though, not of Python, the
language.

You can verify this for yourself by creating a little script:

import sys
dir(sys)

Copy the above to a file, test.py. The lines should not be indented, of
course. Then execute 'python test.py' from the shell. Note the lack of
output.

In vim, just as in Python scripts, if you want output you need to
explicitly ask for it. So try the following in vim:

:py import sys
:py print dir(sys)

BTW, the "python built into vim" is really just the normal python
interpreted, embedded in vim. Everything you know about the Python
language still holds. The main differences are that it doesn't have the
same sort of "interactive mode" that the python interpreter has, and you
have access to he vim module. Documentation for the latter can be found
by executing ':help python-vim'. Yes, the documentation is brief, but it
is fairly complete, as far as I can tell.
Jul 18 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: RJS | last post by:
Hi all, I can't get a py2exe compiled app to run with numarray (numarray-0.5.win32- py2.2). Also wxPythonWIN32-2.3.3.1-Py22 and ActivePython-2.2.1-222. In the sample below, commenting out...
5
by: Edward K. Ream | last post by:
Am I reading pep 277 correctly? On Windows NT/XP, should filenames always be converted to Unicode using the mbcs encoding? For example, myFile = unicode(__file__, "mbcs", "strict") This...
1
by: C. Titus Brown | last post by:
Hi all, while playing with PBP/mechanize/ClientForm, I ran into a problem with the way htmllib.HTMLParser was handling encoded tag attributes. Specifically, the following HTML was not being...
0
by: Brano Zarnovican | last post by:
Hi ! I'd like to init curses and still have working Python interactive command line. I found that you can replace stdin/stdout/stderr like this: #!/usr/bin/python -i import curses import...
4
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3...
7
by: Kirt | last post by:
i have walked a directory and have written the foll xml document. one of the folder had "&" character so i replaced it by "&amp;" #------------------test1.xml <Directory> <dirname>C:\Documents and...
7
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get...
3
by: Pappy | last post by:
SHORT VERSION: Python File B changes sys.stdout to a file so all 'prints' are written to the file. Python file A launches python file B with os.popen("./B 2>&^1 >dev/null &"). Python B's output...
0
by: newbie73 | last post by:
Going through the tutorial on http://swig.org, I created the example files (pasted below). After generating the _wrap file, I tried compiling (using mingw32) and received a lot of undefined...
0
by: bruce | last post by:
Hi Fredrick Thanks for the reply. But since I don't have control of the initial text, is there something with python that will strip/replace this... or are you saying I should do a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.