[Tutor] vim as a python editor

Alan Gauld alan.gauld at btinternet.com
Thu Dec 16 01:30:45 CET 2010


"Paul Griffiths" <paulmg2010 at gmail.com> wrote

> How have those of you who use vim configured it?  I have looked
> on the web but got a bit confused by the advice and options.

I use both IDLE (for simple short scipts) and vim (for bigger
multi-file projects).

I use vim pretty much out of the box, I deliberately don't configure
it because I want it to work the same on any Linux box I log into.
I use the standad Python syntax highlighting scheme.

There is an IDLE-style settings file available somewhere that
will make vim superficially like IDLE, but personally I didn't
find it helped much and I prefer to keep to standard vim.

> - added the following to .bashrc:
>    EDITOR=vim
>    export EDITOR

You should do the same for VISUAL.
Some programs distinguish between EDITOR and VISUAL and
the default for both is ed...

> I open up a terminal in the folder where I keep my python files and
> create two additional tabs in this terminal.  I use the first tab to
> run python, the second one to run vim and the third one for running
> linux commands such as ls to list the folder contents.

I don't use a tabbed console but prefer three windows(*).
One running graphical vim (vim -g), one running the python
interpreter and one a standard shell prompt. My mode of
working is try something in the interpreter, when it works translate
it into vim. Save the file and then run it in the shell window (up 
arrow
is my friend).

(*) I usually have a browser open at the Python documentation too.
And I have Firefox shortcuts/tags set up so I go to my favourite
pages - like the module A-Z listing - in one short code (ie a-z).

I also use split screen view in vim so that within vim I often have
two or three buffers open at once all displayed in a split screen.
One addition I'd like in vim 8 is the ability to have tabbed editor
buffers in addition to split screens. Switching buffers isn't hard
but tabs make it much easier. (Scite has tabs but no split screen
and that's worse, but I'd like both!)

> Is this is a reasonable approach?  Thank you for any feed back.

Works for me, and a lot of other folks too.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list