I've just started to use VIM as a Python editor. However, getting
indentation to work nicely is giving me fits. I've tried a bunch
of different settings--shiftwidth, ts, etc etc.--to get tabs
working the way I want, but can't get things quite right. I'm
hoping some of you python/VIM users can help.
Here's what I want:
1) A tab displays in a width equal to four spaces.
2) <tab> always produces a tab char; it does not substitute spaces.
3) <del> (in edit mode) always deletes the previous character;
it doesn't do anything fancy.
4) <ret> (in edit mode) produces a new line below with the
same leading whitespace as the previous line _unless_ the
previous line ended with ':', in which case an additional
tab character is added.
Here's what I'm getting (settings are shiftwidth=4, ts=4,
every other tab-related setting that I can find that was
8 is four, and I've tried lots of other stuff at the same
time, such as notabexpand). Not all of this happens all
the time, but at least one of these behaviors happens no
matter what settings I've tried:
1) <del> dedents by 8 spaces: ^D dedents by 4 (which is what
I want.
2) <tab> sometimes indents by 4, and sometimes by 8, at
different places in the same file _using the same settings_.
3) Typing a ':' can cause the entire line (including what
has alrady been typed) to dedent or indent. In my view,
this is a very bad no-no.
Hopefully the solution to this sort of thing is easy. If
not, then I guess the search for an editor resumes...
Thanks,
Ken 1 1758
On Sun, 13 Jun 2004 22:28:07 +0000, Kenneth McDonald wrote: I've just started to use VIM as a Python editor. However, getting indentation to work nicely is giving me fits. I've tried a bunch of different settings--shiftwidth, ts, etc etc.--to get tabs working the way I want, but can't get things quite right. I'm hoping some of you python/VIM users can help.
Here's what I want: 1) A tab displays in a width equal to four spaces. 2) <tab> always produces a tab char; it does not substitute spaces. 3) <del> (in edit mode) always deletes the previous character; it doesn't do anything fancy. 4) <ret> (in edit mode) produces a new line below with the same leading whitespace as the previous line _unless_ the previous line ended with ':', in which case an additional tab character is added.
Here's what I'm getting (settings are shiftwidth=4, ts=4, every other tab-related setting that I can find that was 8 is four, and I've tried lots of other stuff at the same time, such as notabexpand). Not all of this happens all the time, but at least one of these behaviors happens no matter what settings I've tried: 1) <del> dedents by 8 spaces: ^D dedents by 4 (which is what I want. 2) <tab> sometimes indents by 4, and sometimes by 8, at different places in the same file _using the same settings_. 3) Typing a ':' can cause the entire line (including what has alrady been typed) to dedent or indent. In my view, this is a very bad no-no.
Hopefully the solution to this sort of thing is easy. If not, then I guess the search for an editor resumes...
Thanks, Ken
Do you have the ft plugin enabled with support for python filetype? You
might want to enable autoindent or smartindent. Also, look and see if your
distribution is setting any stupid defaults. I remember redhat used to set
a bunch of wierd stuff at the site level, and I had to su to root and get
rid of it. You might want to read ':help autoindent'.
Vim takes a lot of time and patience to learn. You would probably benefit
from reading section 5 of the user-manual ('Set Your Settings').
Good Luck
--segphault This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sateesh |
last post by:
Hi,
I am a beginner in Python, and am wondering what is it about the indentation
in Python, without which python scripts do not work properly.
Why can't the indentation not so strict so as to give better freedom to the
user?
Is there any plausible reason behind this?
Cheers!
Sateesh
|
by: Steven Bethard |
last post by:
So, as I understand it, in Python 3000, zip will basically be replaced
with izip, meaning that instead of returning a list, it will return an
iterator. This is great for situations like:
zip(*)
where I want to receive tuples of (item1, item2, item3) from the
iterables. But it doesn't work well for a situation like:
zip(*tuple_iter)
|
by: Joe |
last post by:
Is Python going to support s syntax the does not use it's infamous
whitespace rules? I recall reading that Python might include such a
feature. Or, maybe just a brace-to-indentation preprocessor would be
sufficient.
Many people think Python's syntax makes sense. There are strong
feelings both ways. It must depend on a person's way of thinking,
because I find it very confusing, even after using with Python for some
time, and trying to...
|
by: diffuser78 |
last post by:
I am a newbie to Python. I am mainly using Eric as the IDE for coding.
Also, using VIM and gedit sometimes.
I had this wierd problem of indentation. My code was 100% right but it
wont run because indentation was not right. I checked time and again
but still no success. I rewrote the code over again in VI and it ran.
Can you please explain whats the trick behind the correct indentation.
Thanks
|
by: Xah Lee |
last post by:
Tabs versus Spaces in Source Code
Xah Lee, 2006-05-13
In coding a computer program, there's often the choices of tabs or
spaces for code indentation. There is a large amount of confusion about
which is better. It has become what's known as “religious war” —
a heated fight over trivia. In this essay, i like to explain what is
the situation behind it, and which is proper.
| |
by: Chris |
last post by:
I have an database containing lots of numerical data. I want to write a
browser based interface that will allow selection of various key
parameters and yield tables, plots and/or printouts of the data
according to the selections. Ultimately I want this to run on an
intranet so that others can get access via their browsers.
The application is for in-house use only and not likely to have more
than a few users at any one time. I've managed...
|
by: bearophileHUGS |
last post by:
This is the best praise of semantic indentation I have read so far, by
Chris Okasaki:
http://okasaki.blogspot.com/2008/02/in-praise-of-mandatory-indentation-for.html
A quotation:
I have appreciated that article, and I have personally seen how fast
students learn Python basics compared to other languages, but I think
that it's way more than just indentation that makes the Python
language so quick to learn .
|
by: Almar Klein |
last post by:
Hi Eric,
First of all, I like your initiative.
I'm not sure if I undestand you correctly, but can't you just
increase indentation after each line that ends with a colon?
That's how I do it in my editor. The user would then only need
to specify when to decrease indentation.
Cheers,
Almar
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |