473,396 Members | 1,917 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,396 software developers and data experts.

vim configuration for python

Hello,

I am looking at configuring vim for Python. Most importantly I
need 4 spaces when the tab is hit. I am searching and getting
a bit confused. Does anyone know where I can find a set of
ready made .vimrc and ~/.vim/syntax/python.vim. If could find
c.vim and cpp.vim these would be useful also.

Thanks for any pointer.
Len
--
__________________________________________________ __
Leonard J. Reder
Jet Propulsion Laboratory
Interferometry Systems and Technology Section 383
Email: re***@huey.jpl.nasa.gov
Phone (Voice): 818-354-3639
Phone (FAX): 818-354-4357
Mail Address:
Mail Stop: 171-113
4800 Oak Grove Dr.
Pasadena, CA. 91109
---------------------------------------------------
Jul 19 '05 #1
6 2290
I think you can do

set tabstop=4

also, it's better to

set expandtab

so, the tab will be expanded as space.

HG
On Wed, 25 May 2005 16:36:04 -0700, Leonard J. Reder <re***@jpl.nasa.gov>
wrote:
Hello,

I am looking at configuring vim for Python. Most importantly I
need 4 spaces when the tab is hit. I am searching and getting
a bit confused. Does anyone know where I can find a set of
ready made .vimrc and ~/.vim/syntax/python.vim. If could find
c.vim and cpp.vim these would be useful also.

Thanks for any pointer.
Len


--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 19 '05 #2
I don't know if the binary editions include the Misc directory, but if
you download the Python source you'll find a directory called Misc. In
it, there's a vimrc file.

Jul 19 '05 #3
On 26/05/05, Leonard J. Reder <re***@jpl.nasa.gov> wrote:
Hello,

I am looking at configuring vim for Python. Most importantly I
need 4 spaces when the tab is hit. I am searching and getting
a bit confused. Does anyone know where I can find a set of
ready made .vimrc and ~/.vim/syntax/python.vim. If could find
c.vim and cpp.vim these would be useful also.


The default python.vim in the /usr/share/vim/vim63/ftplugin/ directory
automatically set the shiftwidth to 4 wide (i.e. a <tab> keypress
makes 4 spaces) and automatically uses spaces instead of tab
characters. A tab character in your file will be rendered as 8 wide.

--
Stephen Thorne
Development Engineer
Jul 19 '05 #4
In comp.editors Leonard J. Reder <re***@jpl.nasa.gov> wrote:
Hello,

I am looking at configuring vim for Python. Most importantly I
need 4 spaces when the tab is hit. I am searching and getting
a bit confused. Does anyone know where I can find a set of
ready made .vimrc and ~/.vim/syntax/python.vim. If could find
c.vim and cpp.vim these would be useful also.


The vim distribution already contains python.vim files for syntax,
indenting and general configuration. It also contains a similar set
of c.vim and cpp.vim files. These should all be in the appropriate
subdirectories under $VIMRUNTIME. You might take a look at

:help ftplugins
:help filetype-indent-on
:help filetype-overview
:help usr_43.txt
:help usr_06.txt

If the files supplied with vim for Python don't do what you want,
you might also search the scripts and tips at vim.sf.net for
"python".

HTH,
Gary
Jul 19 '05 #5
DJK
Does anybody know of any scripts to check python syntax when you type
:make?

Jul 19 '05 #6
In comp.editors DJK <dk*****@gmail.com> wrote:
Does anybody know of any scripts to check python syntax when you type
:make?


The problem I had doing this with Python was that the Python
interpreter spits out errors in the opposite order from that in
which I wanted to traverse them in vim's quickfix error list. I
wrote the following compiler file and helper script to work around
this. I don't use Python very often and haven't used in it a while,
so this still isn't very polished, but you might find it useful
anyway. Note also that I did this on a Unix system.

------------------------- compiler/python.vim --------------------------
" Vim compiler file
" Compiler: Python
" Maintainer: Gary Johnson <ga******@spk.agilent.com>
" Last Change: 2002-06-26 00:27:56

if exists("current_compiler")
finish
endif
let current_compiler = "python"

setlocal makeprg=python\ %
setlocal shellpipe=2>&1\ \|\ ~/.vim/tools/efm_filter.py\ \|\ tee
" Note: efm_filter.py could be rewritten to send its input to stdout
" and to write its output to the file given on the command line. This
" way the user could see the familiar output from Python while the
" quickfix error file received the format the vim can understand. E.g.,
"
" setlocal shellpipe=2>&1\ \|\ ~/.vim/tools/efm_filter.py
"
" or
"
" setlocal shellpipe=2>&1\ \|\ tee\ /dev/tty\ \|\ ~/.vim/tools/efm_filter.py

setlocal errorformat=\ \ File\ \"%f\"\\,\ line\ %l\\,\ in\ %*[^\\,]\\,\ %m
------------------------------------------------------------------------

------------------------- tools/efm_filter.py --------------------------
#!/usr/bin/env python

import sys
import string

errors = sys.stdin.readlines()

message = errors.pop()[:-1]
errors.reverse()

for error in errors:
if string.find(error, ' File') == 0:
print error[:-1] + ", " + message
message = "Traceback"
------------------------------------------------------------------------

To use these, put them in the indicated directories under ~/.vim and
execute ":compiler python". Also see ":help compiler".

HTH,
Gary
Jul 19 '05 #7

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

Similar topics

1
by: Raphael Bossek | last post by:
Hi, I search for a module where programming of installation and configuration procedures based on question and answer/list selection/single line edit ect. steps can be done easy. I know only...
5
by: Karthikesh Raju | last post by:
Hi All, i am wondering about the best way to read in a configuration file that goes like: ########### source_dir = '/home/karthik/Projects/python' data_dir =...
7
by: Famille Delorme | last post by:
Sorry if this discussion are already submited, but I don't find anything really interresting for me. And sorry for my bad english, it is not my native language. I wrote a program in Python for a...
4
by: sebsauvage | last post by:
Hello. In one of my programs ( http://sebsauvage.net/python/webgobbler/ ), I have a global dictionnary containing the whole program configuration. Sample follows: CONFIG = {...
5
by: Aaron | last post by:
Hi, I'm interested in creating a large number of configuration files which I have no experience doing in python. The fields will be static for the most part. But design changes and I might want...
0
by: HIL | last post by:
Hi everybody, I wrote a python script to setup my network interface under Linux. To perform it, I use directly from my python script external programs as 'ifconfig' and 'route' ans I fill the...
2
by: metaperl | last post by:
Inheritance needed in app configuration ============================= I have an ftp server that a number of vendors connect into to upload a file to their directory. In OO terms, we would have ...
0
by: metaperl | last post by:
A Comparison of Python Class Objects and Init Files for Program Configuration ============================================================================= Terrence Brannon bauhaus@metaperl.com...
5
by: blaine | last post by:
The wxPython group is a bit stale compared to this group, so I'll give it a shot :) (READ: Originally when I started htis post, Python 2.5 at the shell did not work (identical behavior to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.