473,395 Members | 2,253 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,395 software developers and data experts.

how do you move to a new line in your text editor?

This is a real small point, but I'd like to hear what others do in this
case. It's more an 'administrative' type question than Python code
question, but it still involves a bit of syntax.

One thing I like to do is use tabs for my indentation, because this
makes it easy to outdent when I need to start a new line in column 1. I
can press backspace once and move 4 spaces to the left.

But I read in the PEP that spaces are recommended over tabs. If this is
the case, it would involve pressing backspace 4 times (or 8, etc.) to
get back to column 1.

So I'm wondering, how do you all handle moving around in your code in
cases like this? Is there some sort of consistency to these things that
you can write rules for your text editor to know when to outdent? It
doesn't seem like you can do this reliably, though.
Mar 2 '06 #1
24 2512
John Salerno wrote:
So I'm wondering, how do you all handle moving around in your code in
cases like this? Is there some sort of consistency to these things that
you can write rules for your text editor to know when to outdent? It
doesn't seem like you can do this reliably, though.


Emacs, at least, outdents reliably with spaces. Probably some other
editors do as well, though I was kind of surprised to find out that
some editors have (compared to Emacs) weak indent inference.

If editing with spaces annoys you, it might be possible with your
editor (which seems to have a variable tab stop) to edit the file with
tabs, but save it with spaces.
Carl Banks

Mar 2 '06 #2
Carl Banks wrote:
John Salerno wrote:
So I'm wondering, how do you all handle moving around in your code in
cases like this? Is there some sort of consistency to these things that
you can write rules for your text editor to know when to outdent? It
doesn't seem like you can do this reliably, though.


Emacs, at least, outdents reliably with spaces. Probably some other
editors do as well, though I was kind of surprised to find out that
some editors have (compared to Emacs) weak indent inference.

If editing with spaces annoys you, it might be possible with your
editor (which seems to have a variable tab stop) to edit the file with
tabs, but save it with spaces.
Carl Banks


I use UltraEdit right now, and it is possible to convert spaces and tabs
back and forth, but it's just an extra step. I was thinking about trying
vim, as I've heard it's easier to learn than emacs.
Mar 2 '06 #3

John Salerno wrote:
Carl Banks wrote:
John Salerno wrote:
So I'm wondering, how do you all handle moving around in your code in
cases like this? Is there some sort of consistency to these things that
you can write rules for your text editor to know when to outdent? It
doesn't seem like you can do this reliably, though.


Emacs, at least, outdents reliably with spaces. Probably some other
editors do as well, though I was kind of surprised to find out that
some editors have (compared to Emacs) weak indent inference.

If editing with spaces annoys you, it might be possible with your
editor (which seems to have a variable tab stop) to edit the file with
tabs, but save it with spaces.


I use UltraEdit right now, and it is possible to convert spaces and tabs
back and forth, but it's just an extra step. I was thinking about trying
vim, as I've heard it's easier to learn than emacs.


Well, they don't call vi the "Very Intuitive" editor for nothing. I
suspect if you're not used to the modes and movement keys and stuff
it'll be a little steep learning at first. More power to you if you
can get used to that.

You wouldn't know if Ultraedit has some kind of hook mechanism (whereby
it can execute a macro or script or something upon loading/saving).
That could solve your problem. Obviously, having to manually convert
isn't too helpful.

Carl Banks

Mar 2 '06 #4
John Salerno wrote:
But I read in the PEP that spaces are recommended over tabs. If this is


If you like tabs, stick with tabs. There isn't any reason to use spaces
unless your boss is demanding it. Tabs are the slightly better choice,
in my humble opinion.

That said, you should be able to tell your editor how to behave in the
indent/unindent case, no matter whether you use tabs or spaces. If not,
time to switch editors! ;)

--
Paul
Mar 2 '06 #5
Carl Banks wrote:
You wouldn't know if Ultraedit has some kind of hook mechanism (whereby
it can execute a macro or script or something upon loading/saving).
That could solve your problem. Obviously, having to manually convert
isn't too helpful.


I'll have to check on that. I know I can do macros and such, but I'll
have to see about having it done automatically.
Mar 2 '06 #6
Paul McNett wrote:
That said, you should be able to tell your editor how to behave in the
indent/unindent case, no matter whether you use tabs or spaces. If not,
time to switch editors! ;)


I definitely can, I'm just a little unsure about what the special
outdenting cases might be. The way to do it in UltraEdit is to specify
which characters (on a preceding line) an outdented line should follow,
so obviously for a C language you could specify Unindent = '}' and that
would help a lot. But with Python it seems more difficult to figure out
the cases where you would outdent.

Mar 2 '06 #7
John Salerno wrote:
I use UltraEdit right now, and it is possible to convert spaces and tabs
back and forth, but it's just an extra step. I was thinking about trying
vim, as I've heard it's easier to learn than emacs.

Absolutely. It's also easier to learn to ride a Huffy than a Schwinn,
Hondas are easier to drive than Toyotas, and Evian is easier to drink
than Poland Spring.

Do yourself a favor and learn them both. Then decide which is best for you.

Bill
Mar 2 '06 #8
Bill Scherer wrote:
John Salerno wrote:
I use UltraEdit right now, and it is possible to convert spaces and
tabs back and forth, but it's just an extra step. I was thinking about
trying vim, as I've heard it's easier to learn than emacs.

Absolutely. It's also easier to learn to ride a Huffy than a Schwinn,
Hondas are easier to drive than Toyotas, and Evian is easier to drink
than Poland Spring.

Do yourself a favor and learn them both. Then decide which is best for you.

Bill


Point taken. I like to just pick something and go with it, but sometimes
I just need to experiment first.
Mar 2 '06 #9
On Thu, 02 Mar 2006 18:39:55 GMT
John Salerno <jo******@NOSPAMgmail.com> wrote:
But I read in the PEP that spaces are recommended over tabs. If this is
the case, it would involve pressing backspace 4 times (or 8, etc.) to
get back to column 1.

So I'm wondering, how do you all handle moving around in your code in
cases like this? Is there some sort of consistency to these things that
you can write rules for your text editor to know when to outdent? It
doesn't seem like you can do this reliably, though.


I use Vim, use spaces, and have no problems. It has a shorttabstop
option, which causes backspace to backspace to the preceding multiple
of <tabwith> spaces when the curser is after a set of spaces at the
beginning of the line. It feels like I'm using tabs, but I'm not.

Also, there's some Python indenting/folding macros I picked up from Vim
Online (don't remember where exactly), that provide an indent/outdent
pair of key mappings, which also work perfectly with my usage of 4
spaces.

- Michael

--
mouse, n: a device for pointing at the xterm in which you want to type.
-- Fortune
Mar 2 '06 #10
> I use Vim, use spaces, and have no problems. It has a
shorttabstop option, which causes backspace to backspace
to the preceding multiple of <tabwith> spaces when the
curser is after a set of spaces at the beginning of the
line. It feels like I'm using tabs, but I'm not.
In addition, within insert-mode in vim, you can use
control+D and control+T to exdent/indent the current one
'shiftwidth' worth. If your 'shiftwidth' setting is the
same as your 'tabstop' setting, you'll get the expected
behavior. There are also settings to control whether tabs
get interpreted as spaces or vice-versa (see ":help
expandtab"). I presume Emacs has similar settings.
However, Vim can be tweaked to handle whatever style you're
comfortable with (or whatever style management shoves down
on you). The "shiftwidth = tabstop" also holds for the ">"
and "<" operators, so in Normal mode, you can use ">>" to
indent the current line, or "<3j" to exdent the current line
and the three below it. All sorts of magic can be worked
with this :)
Also, there's some Python indenting/folding macros I
picked up from Vim Online (don't remember where exactly),
that provide an indent/outdent pair of key mappings,
which also work perfectly with my usage of 4 spaces.


If you pop over to www.vim.org you'll find a search
functionality to search both the "tips" and "scripts"
section. Just searching for "python" yields a bounty of
fun. For folding, because python uses indenting, you can
just set your 'foldmethod' setting to "manual".

Okay...this has drifted just a wee spot off-topic. However,
the vim mailing list is a friendly place--so if you have any
questions, feel free to drop in.

-tkc



Mar 2 '06 #11
John,
This is a real small point


No point is small when you apply it hundreds of times a day. I spent
quite a bit of time on this element and ended up allowing conversion
from tabs to spaces and the reverse. Who knows what you'll find in the
world of ASCII.

Historically, Tabs were stops on the typewriter carriage, a control
function. This Tabs = Spaces thing came about largely because of
cursor bondage.

So how do YOU think of a Tab key? Is it a data key or a control key?

Internally, I treat Tab (and Shift Tab) as a navigation (control) key
instead of pumping in lots of spaces. It seems more useful that way.
But then Sudden View doesn't have "cursor bondage" to worry about.

Sudden Disruption

Try Sudden View - for the art of editing text
Beta test now in progress at...
http://www.sudden.net/

Mar 3 '06 #12
> One thing I like to do is use tabs for my indentation, because
this makes it easy to outdent when I need to start a new line
in column 1. I can press backspace once and move 4 spaces to
the left.
Zeus has a Smart Backspace feature (configurable on or off) where
by it will try to line up the current line with the lines of code
above on any backspace key press.

This means that in the case you describe a backspace will always
move back 4 spaces whether the white space is made up of tabs
or spaces.
But I read in the PEP that spaces are recommended over tabs. If
this is the case, it would involve pressing backspace 4 times (or
8, etc.) to get back to column 1.


It only takes one key press if you are using Zeus ;)

Jussi Jumppanen
Author: Zeus for Windows
Zeus for Windows IDE
http://www.zeusedit.com

Mar 3 '06 #13
John Salerno wrote:
But I read in the PEP that spaces are recommended over tabs. If this is
the case, it would involve pressing backspace 4 times (or 8, etc.) to
get back to column 1.


In the editor which I use, pressing the tab key indents the current line
under the previous one the first time you press it near the start of a
line, then indents a further 4 spaces every other time you press it. The
backspace key deletes the previous character, unless there is only
whitespace before it in the line in which case it deletes back to the
previous tabstop.

This sort of configuration is common to most programming editors: keys
should work in an intuitive manner and don't have to be dumb.

Mar 3 '06 #14
John Salerno wrote:
This is a real small point, but I'd like to hear what others do in this
case. It's more an 'administrative' type question than Python code
question, but it still involves a bit of syntax.

One thing I like to do is use tabs for my indentation, because this
makes it easy to outdent when I need to start a new line in column 1. I
can press backspace once and move 4 spaces to the left.

But I read in the PEP that spaces are recommended over tabs. If this is
the case, it would involve pressing backspace 4 times (or 8, etc.) to
get back to column 1.
you can still use tabs for editing, and if you want to provide space indented
code you can write a small tab2space converter in python

more seriously, most of the editors (at least Emacs and vim) may use tab for
automatic indentation but convert the tabs to a specified space number

Eric
-- Le lecteur c'est Outlook express (ceci explique sans doute celà)

Outlook Express, c'est fait pour demander comment configurer Emacs
pour lire le courrier et les news.
-+- GK in Guide du linuxien pervers - "De l'utilité de Outlook" -+-
Mar 3 '06 #15
On Thu, 02 Mar 2006 18:58:50 GMT, John Salerno wrote:
I use UltraEdit right now, and it is possible to convert spaces and tabs
back and forth, but it's just an extra step.


I wouldn't definitely suggest UltraEdit to code Python.
Probably you should try scite.

I'm using TextMate (but it's MacOS only). When on Linux I use Emacs or vim
(depends on what I find on the machine). On Windows I prefer gvim to Emacs,
since I've not yet found a well integrated Emacs distribution (I said I
did't find it, not that it doesn't exist).
--
USB Priests for only 10$
Mar 3 '06 #16
On Linux you can try out Scribes. It has a function to convert tabs to
spaces. Personally, I use tabs in all my projects.

http://scribes.sf.net/snippets.htm

http://scribes.sf.net/

Mar 3 '06 #17
Mc Osten wrote:
On Thu, 02 Mar 2006 18:58:50 GMT, John Salerno wrote:
I use UltraEdit right now, and it is possible to convert spaces and tabs
back and forth, but it's just an extra step.


I wouldn't definitely suggest UltraEdit to code Python.


Why do you say that?
Mar 3 '06 #18
On Fri, 03 Mar 2006 16:48:11 GMT, John Salerno wrote:
Why do you say that?


Because I tried it and it just lacks a lot of functionality you get with
TextMate or Emacs. It is quite stupid when indenting, just to name one.

--
USB Priests for only 10$
Mar 3 '06 #19
John Salerno wrote:
This is a real small point, but I'd like to hear what others do in this
case. It's more an 'administrative' type question than Python code
question, but it still involves a bit of syntax.

One thing I like to do is use tabs for my indentation, because this
makes it easy to outdent when I need to start a new line in column 1. I
can press backspace once and move 4 spaces to the left.

But I read in the PEP that spaces are recommended over tabs. If this is
the case, it would involve pressing backspace 4 times (or 8, etc.) to
get back to column 1.

So I'm wondering, how do you all handle moving around in your code in
cases like this? Is there some sort of consistency to these things that
you can write rules for your text editor to know when to outdent? It
doesn't seem like you can do this reliably, though.


I apologize for the OT nature of this question, but it's at least
on-topic as far as this thread goes! :)

Anyway, one problem I have in UltraEdit when I'm writing HTML is that
linewrapping is never handled quite right when using soft returns. Hard
returns screw things up when you need to edit the text, so it's not a
good option. But with soft returns, the lines wrap to column 1 of the
next line, and they don't line up properly (indentation-wise) with the
line being continued.

Do emacs or vim allow you to line up wrapped lines like this without
actually inserting return or space or tab characters in the text?
Mar 3 '06 #20
Mc Osten <ri**@despammed.com> writes:
Because I tried it and it just lacks a lot of functionality you get with
TextMate or Emacs. It is quite stupid when indenting, just to name one.


This is the main motive I don't use PyDev with Eclipse... It is a lot more
stupid than python-mode on Emacs with regards to indenting... :-(

--
Jorge Godoy <go***@ieee.org>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
Mar 4 '06 #21
Which indenting features do you find missing? Note: 1.0.3 -- still
unreleased -- has implemented if / elif /else auto unindent...

Jorge Godoy wrote:
Mc Osten <ri**@despammed.com> writes:
Because I tried it and it just lacks a lot of functionality you get with
TextMate or Emacs. It is quite stupid when indenting, just to name one.


This is the main motive I don't use PyDev with Eclipse... It is a lot more
stupid than python-mode on Emacs with regards to indenting... :-(

--
Fabio Zadrozny
------------------------------------------------------
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

Pydev Extensions
www.fabioz.com/pydev

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com
Mar 6 '06 #22
Fabio Zadrozny <fa****@esss.com.br> writes:
Which indenting features do you find missing? Note: 1.0.3 -- still unreleased
-- has implemented if / elif /else auto unindent...


The most basic one is not having my code moving forward with sucessive TABs
pressed. When I press TAB on Emacs it use a soft tab (i.e. what Eclips calls
'space-tab') and indent my code to the next indentation level and stop
indenting. Even when in the middle of the line and if I'm in the beginning of
the line it moves the cursor to the beginning of the code.

Another that is related is pressing that to remove indentation from the code:
TAB means go to the next indentation level, no matter where the line starts.

The third is using BACKSPACE to remove indentation from my code: if I'm in a
nesting level and I want to move my code one level down, I have to press
backspace 'n' times (n == the number of spaces used by soft tabs in my Eclipse
configuration) on lines where I have code. (The menu option 'Python
backspace' doesn't work.)

These are the most annoying things since in Python indentation matters and we
use it a lot.

--
Jorge Godoy <go***@ieee.org>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
Mar 6 '06 #23
Ok, I'm putting those in my 'todo-list' ;-)

-- keep an eye open for future releases...

Cheers,

Fabio

Jorge Godoy wrote:
Fabio Zadrozny <fa****@esss.com.br> writes:
Which indenting features do you find missing? Note: 1.0.3 -- still unreleased
-- has implemented if / elif /else auto unindent...


The most basic one is not having my code moving forward with sucessive TABs
pressed. When I press TAB on Emacs it use a soft tab (i.e. what Eclips calls
'space-tab') and indent my code to the next indentation level and stop
indenting. Even when in the middle of the line and if I'm in the beginning of
the line it moves the cursor to the beginning of the code.

Another that is related is pressing that to remove indentation from the code:
TAB means go to the next indentation level, no matter where the line starts.

The third is using BACKSPACE to remove indentation from my code: if I'm in a
nesting level and I want to move my code one level down, I have to press
backspace 'n' times (n == the number of spaces used by soft tabs in my Eclipse
configuration) on lines where I have code. (The menu option 'Python
backspace' doesn't work.)

These are the most annoying things since in Python indentation matters and we
use it a lot.

--
Fabio Zadrozny
------------------------------------------------------
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

Pydev Extensions
www.fabioz.com/pydev

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com
Mar 6 '06 #24
John Salerno wrote:
So I'm wondering, how do you all handle moving around in your code in
cases like this? Is there some sort of consistency to these things that
you can write rules for your text editor to know when to outdent? It
doesn't seem like you can do this reliably, though.

Under windows, I'm using SciTE which is an extremely lightweight editor,
but it handlers "smart unindent": pressing backspace at the beginning of
a line unindents one level, whether you're indenting with tabs (and need
to remove a tab) or space (and need to remove 2, 4, 8 spaces) doesn't
matter. And since SciTE also has Visual Studio's smart home key (home
brings you first at the beginning of the text == current indent, then at
the beginning of the line itself == indent level 0)

SciTE also features "somewhat smart" indent from time to time: it
indents one level after a ":". This is good for if/else/while/..., but
it also indents one level after ":" in dicts, which is way bad.
Oh, and it automatically unindents one level after a "return" statement.

Other than that, SciTE doesn't really "understand" python, if you want a
really pythonic editor you need to check Stani's Python Editor, WingsIDE
or Komodo.
Mar 6 '06 #25

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

Similar topics

15
by: ajikoe | last post by:
Hello, I use windows notepad editor to write text. For example I write (in d:\myfile.txt): Helo World If I open it with python: FName = open(d:\myfile.txt,'r')
2
by: Roger | last post by:
I'm trying to build a controls editor, that given a control (textbox) somewhere on a form, it can be moved using the mouse to drag-drop I have a simple form with a square text box (1" x 1") and...
3
by: Jan E Andersen | last post by:
Is there an option for this It woul certainly make debugging much easier JE
2
by: Brian Henry | last post by:
Is there any way to turn off that annoying line that breaks apart methods in the VS.NET text editor? I know you can turn off other things on the text editor, but I can not figure out how to turn...
4
by: David Beoulve | last post by:
Stupid question... but thanks to Jon's page here: http://www.yoda.arachsys.com/csharp/complete.html I now find myself having a good reason to keep my code lines shorter (which i tend to do for...
1
by: carlg | last post by:
There seem to be plenty of Javascript implemented WYSIWYG editors for editing rich text in a web browser, but I haven't been able to find one that shows line numbers. Even if that was the only...
9
by: Peter Hartlén | last post by:
I understand that the\n and \r only means something to the C# compiler so when retrieving a line like "Hello\r\nWorld" from a resource file (localized form or self made resource file), it prints...
4
by: MartinRinehart | last post by:
Thinking about unclosed multi-line quotes. When you open a multi-line quote (type '"""') what does your editor do? Does it color the remainder of your text as a quote, or does it color the line...
2
by: noe1818 via AccessMonster.com | last post by:
Can anyone tell my why this isn't working? Me!.top=(1440/2.54)*16.78-*0.4) I want it so that for every 1 change in , a rectangular box moves 0.4 units closer to the top. The 1440/2.54...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
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,...
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
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.