Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   how do you move to a new line in your text editor? (http://www.velocityreviews.com/forums/t355022-how-do-you-move-to-a-new-line-in-your-text-editor.html)

John Salerno 03-02-2006 06:39 PM

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.

Carl Banks 03-02-2006 06:51 PM

Re: how do you move to a new line in your text editor?
 
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


Paul McNett 03-02-2006 06:52 PM

Re: how do you move to a new line in your text editor?
 
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



John Salerno 03-02-2006 06:58 PM

Re: how do you move to a new line in your text editor?
 
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.

Carl Banks 03-02-2006 07:09 PM

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

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


Bill Scherer 03-02-2006 07:15 PM

Re: how do you move to a new line in your text editor?
 
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

John Salerno 03-02-2006 07:16 PM

Re: how do you move to a new line in your text editor?
 
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.

John Salerno 03-02-2006 07:18 PM

Re: how do you move to a new line in your text editor?
 
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.


John Salerno 03-02-2006 08:17 PM

Re: how do you move to a new line in your text editor?
 
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.

Michael Ekstrand 03-02-2006 09:18 PM

Re: how do you move to a new line in your text editor?
 
On Thu, 02 Mar 2006 18:39:55 GMT
John Salerno <johnjsal@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


All times are GMT. The time now is 12:32 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.