Editor with support for mixed spaces and tabs?

Go To StackoverFlow.com

4

Is there any text editor (for Windows) which has good support for mixed spaces and tabs, for languages like C++/C#/Java (and bonus points for Python/Ruby/etc.)?
i.e. Tabs would be used for indentation, and spaces would be used for alignment.


As an example, say represents a tab, . represents a space, and represents the current position of the cursor.

If I have the following in my text editor:

template<class T1,
.........class T2>
class Foo
{
  → template<int M,
  → .........int N>
  → void foo(int bar,■
}

I want to be able to press the ⏎ Enter key, and see:

template<class T1,
.........class T2>
class Foo
{
  → template<int M,
  → .........int N>
  → void foo(int bar,
  → .........■
}

after which I should be able to type the next parameter, close the parenthesis, and press ⏎ Enter, and have the cursor automatically go back to the correct position, using tabs/spaces as shown:

template<class T1,
.........class T2>
class Foo
{
  → template<int M,
  → .........int N>
  → void foo(int bar,
  → .........int baz) {
  →  →  ■
}

Of course, if I pressed Backspace or Shift-Tab or whatever, it should clear to the appropriate stop -- which is probably the beginning of the indent that is of the same type as the current one. And stuff like that.

Note:

I realize that many editors (SciTE, Visual Studio, and probably Emacs, Vim, etc.) can be scripted with regexes (or crude parsing code) to do something that works, oh, 80% of the time.

But I'm looking for something with hopefully a bit more robust support, with lexing support for the current language to figure out what to do. After all, editor mistakes shouldn't be harder to fix than indenting manually in the first place -- otherwise I'd just do it manually instead, and never use the feature!

2012-04-04 02:45
by Mehrdad
@Luiggi: Notepad++ sucks, especially in this particular regard. Good question, by the way. I think the problem is that most people don't use this type of indentation (although I like it really much if it lines up like this - Niklas B. 2012-04-04 02:48
jozefg: That's unarguably true, but can you point at how this particular problem can be solved in VIM? I'd be interested in tha - Niklas B. 2012-04-04 02:50
5 minutes into the thread and already theres " sucks" and "use " in the comments. Way to derail a legitimate question, folks - corsiKa 2012-04-04 02:52
Using mixed tabs and spaces in layout-sensitive languages like Python is really an error. And in all others, it's just ugly - Cat Plus Plus 2012-04-04 03:29
@CatPlusPlus: Yeah I realized the Python issue after I posted... scratch that then. But I don't really think it's ugly in general -- it actually lines things up quite well. : - Mehrdad 2012-04-04 03:30
Just indent with spaces. Tabs are more trouble than it's worth - Cat Plus Plus 2012-04-04 03:30
@CatPlusPlus: I'll keep that in mind - Mehrdad 2012-04-04 03:31
@Close-Voter: I'm pretty sure development tools should be on StackOverflow.. - Mehrdad 2012-04-04 03:31
I would have thought given any any decent scriptable editor you would be able to implement this feature as a macro script. Just write a macro script that implements this feature and bind that macro to the enter key - jussij 2012-04-17 14:12


1

Not sure if this qualifies to be an answer. However, my gvim with current vimrc does exactly what you are looking for with tabs and spaces. I strongly recommend using Gvim. Its a matter of personal choice, there may be better or worse editors.

You can highlight any language on vim using se syn= command

What you won't find is lexing support or the intelli-sense - at lease in usable ways.

Have a look at the screenshot. Here is a link to vimrc that I have adapted.

EDIT I really suspect if there is an editor utopia so to speak. You may have to strike a balance based on "right tool for the job" principle.

enter image description here

2012-04-04 03:26
by ring bearer
+1 looks very nice, I'll try and see if I can get gvim working. Thanks - Mehrdad 2012-04-04 03:33
I think I got it to work... it'll take me a while to get used to vim :) but I'm liking it! Thanks - Mehrdad 2012-04-04 16:14
Nope it doesn't work... see here - Mehrdad 2012-04-04 16:27
sorry @Mehrdad - I fail to understand what you want to highligh - ring bearer 2012-04-04 16:33
The indentation didn't go back to the parenthesis, is what I'm trying to highlight - Mehrdad 2012-04-04 17:13
Ads