Author Topic: suggestion for python indent in slickedit  (Read 7042 times)

greggman

  • Senior Community Member
  • Posts: 277
  • Hero Points: 14
suggestion for python indent in slickedit
« on: June 21, 2007, 04:43:32 am »
I'm wondering if there is a way to get slickedit to both #1 smart indent and #2 follow the example of the line before it.

I get python files, some with tabs, some with spaces. With smart indenting on if I press enter and a new line is inserted the new line is indented using tabs or spaces depending on the setting in slickedit. Unfortunately that's not useful. What I need it to do is look at the file it's editing and "do the right thing". If the previous valid line is using spaces then smart indent with spaces. If the previous valid line is using tabs then indent with tabs. If it did this then I could edit any python file.  By valid I mean if the previous line is blank or is a comment only line then slickedit needs to look up to the next line until it finds one it can deduce whether or not to use tabs or spaces.

Is there a way to set slickedit's options to accomplish this?
« Last Edit: June 22, 2007, 01:40:07 am by greggman »

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
Re: python indent not correct in v11
« Reply #1 on: June 22, 2007, 12:09:23 am »
I'm wondering if there is a way to get slickedit to both #1 smart indent and #2 follow the example of the line before it.

I get python files, some with tabs, some with spaces.


Before You do anything, I would suggest you use a utility (or write a simple python script)  to remove one or the other (tabs or spaces). That should make your job easier. Then try loading the file into Slick.

Mixing tabs and spaces is generally not a good thing to do. Using tabs in general is very bad.

Most decent editors can be configured to uses spaces instead of tabs, and often have a "replace this with that" feature. You can replace tabs with spaces or spaces with tabs.

I write in Python daily- and always use spaces as a practice.

StephenW

  • Senior Community Member
  • Posts: 189
  • Hero Points: 21
Re: python indent not correct in v11
« Reply #2 on: June 22, 2007, 01:34:20 am »
SlickEdit is, of course, a "decent editor".  Use "Edit/Other/Tabs to Spaces".

greggman

  • Senior Community Member
  • Posts: 277
  • Hero Points: 14
suggestion for python indent in slickedit
« Reply #3 on: June 22, 2007, 01:37:30 am »
If it was just me that would be great solution but I'm on a large team and I have no control over what other programmers use.

If slickedit did what I suggested then things would "just work" and would not have to worry about what other programmers are doing or whether or not their editors selfishly decided to convert tabs to spaces or spaces to tabs.

« Last Edit: June 22, 2007, 01:39:30 am by greggman »

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
Re: suggestion for python indent in slickedit
« Reply #4 on: June 22, 2007, 04:32:05 pm »
If it was just me that would be great solution but I'm on a large team and I have no control over what other programmers use.

If slickedit did what I suggested then things would "just work" and would not have to worry about what other programmers are doing or whether or not their editors selfishly decided to convert tabs to spaces or spaces to tabs.

Slick is highly configurable/programmable. If something doesn't work the way you expect, and is implemented in a macro, then you can copy the macro and edit it to do things your way.

That's what I did with Selective Display.

We have coding guidelines/conventions where I work, so everyone must follow them, although they are free to use any editor they choose. For future projects, it may be worth suggesting to the team that everyone use the same indent settings.


greggman

  • Senior Community Member
  • Posts: 277
  • Hero Points: 14
Re: suggestion for python indent in slickedit
« Reply #5 on: June 22, 2007, 05:18:53 pm »
I'm aware that slickedit is programmable. I have macros in slickedit's macro site for download...sheesh

Can you not agree a feature like this would be useful as a default for slickedit python editing? Load up any python file made by anyone on any team and start editing and not have to worry if they were using tabs or spaces. That sounds like a win-win to me.  If it can already do this out of the box without creating custom macros great. If not then I believe it's a good suggestion.


garion911

  • Senior Community Member
  • Posts: 190
  • Hero Points: 13
Re: suggestion for python indent in slickedit
« Reply #6 on: June 22, 2007, 05:43:22 pm »
I'm not sure how possible it really is to do something like that.. I suppose if the file is consistently indented, using only tabs, or only spaces, then maybe..

But the problem comes in if someone mixes both into the file.. For example:

(using _ for a single space, ---- for a single tab)

Code: [Select]
____def blah():
____----if something:

Now when you hit enter at the end of the if line, whats slick supposed to enter as the next indentation? 4 Spaces, or a single tab?

Personally, I say have some sort of coding standards.. Makes for less issues down the road..





greggman

  • Senior Community Member
  • Posts: 277
  • Hero Points: 14
Re: suggestion for python indent in slickedit
« Reply #7 on: June 22, 2007, 06:59:15 pm »
It should copy the line above it

Code: [Select]
____def blah():
____----if something:
____----....new stuff

The "...." can be either a tab or spaces. It doesn't matter. All that matters is that when I run the program it runs correctly.

I suspect the case of mixed spaces and tabs rarely comes up. If the previous line is all tabs then use a tab for "....", if it's all spaces use spaces for "...."  If it's mixed use whatever. At that point it doesn't matter. I suppose you could also check the line below in that case or even always.

Right now I get this these two cases

case 1: file is tabs but slickedit puts in spaces
Code: [Select]
____def blah():
________if something:
------------new stuff

case 2: file is spaces but slickedit puts in tabs
Code: [Select]
----def blah():
--------if something:
____________new stuff

In either case IF I'm lucky python will give an error. If I'm unlucky the program will silently run incorrectly. Neither case is good and neither case is visible which is why I'm suggesting the feature.
« Last Edit: June 22, 2007, 07:02:26 pm by greggman »

ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: suggestion for python indent in slickedit
« Reply #8 on: June 22, 2007, 08:51:06 pm »
We don't have a feature that addresses this currently, but we have a feature tentatively planned for SlickEdit 2008 that should address this.

--Scott

greggman

  • Senior Community Member
  • Posts: 277
  • Hero Points: 14
Re: suggestion for python indent in slickedit
« Reply #9 on: June 22, 2007, 08:55:01 pm »
That's great! Thank you!