Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users should have intelligent autoindenting in the notebook #442

Closed
certik opened this issue May 14, 2011 · 13 comments
Closed

Users should have intelligent autoindenting in the notebook #442

certik opened this issue May 14, 2011 · 13 comments
Assignees
Labels
Milestone

Comments

@certik
Copy link

certik commented May 14, 2011

If you write this:

def f(x):
    a = 5
b = 5

the b=5 part should be automatically indented in the function f(x). But it isn't, and that's a bug. This is in codemirror.

@ellisonbg
Copy link
Member

Are you sure, I thought I turned autoindenting off (which it should be by default).

@certik
Copy link
Author

certik commented May 15, 2011

I tried again, and indeed, all autoindenting is off. Sorry for that, I must have made a mistake.

But I vote to have the following feature on: "keep the indentation level". so if I am indented twice (2x4spaces), I would like to just keep pressing "enter", instead of always pressing "tab" twice in order to continue writing the function.

@certik
Copy link
Author

certik commented May 15, 2011

And I vote for the following feature "if you press BACKSPACE", it would delete 4 spaces at once, assuming only spaces are to the left of the cursor. That way, it is supper easy to get to the beginning of the line, after the function definition is done.

That's how my VIM is configured, and I never had any problems with this behavior.

@certik
Copy link
Author

certik commented May 16, 2011

So this option in notebook.js is responsible for it:

        enterMode : 'flat',

Documentation is here:
http://codemirror.net/manual.html
and both keep and indent options work better imho.

The only annoying thing is that backspace doesn't delete 4 spaces. I'll see if I can implement it.

But I like 'indent' the most.

@ellisonbg
Copy link
Member

In general I am not fond of autoindentation, but I am open to it possibly if we can get backspace to delete 4 spaces at a time. Otherwise you have to type 4 key strokes to dedent a level, which will only anger users. The golden rule of UI design is "don't anger your users" But all of the final usability decisions like this will be answered by doing actual usability studies with real users. This site was highly recommended to me:

http://www.usertesting.com/

@certik
Copy link
Author

certik commented May 16, 2011

You will anger some users anyway. For example I am angered with the flat mode (default), because it doesn't keep the indentation, so it's really not usable for me. At least using keep would be great. Fortunately, this is easy to fix, just one line of code, so no big deal.

However, the backspace is also annoying (super annoying to be honest), so it needs to be fixed. I have looked into it, but not have time at the moment, but eventually I'll get to it.

@ellisonbg
Copy link
Member

I agree that some users will always be angered or annoyed. The goal of usability testing is to identify what those annoyances are and for whom. For example, if usability testing shows that 90% of users prefer "keep" for the indentation mode, then we will use that, even if 10% of users don't like it. But, in things like this, we will eventually have a config section that allows advanced (or annoyed) users to adjust things to their liking.

In spite of all of this, I do think that "keep" is probably a good default if we can fix the backspace bug. But until then, I think we should leave it as is.

One last important point on this. We (developers) tend to be horrible judges in areas like this because we are not "typical" users. I am guilty of this as much as any of us.

@certik
Copy link
Author

certik commented May 16, 2011

I agree. Keeping indentation, that is such a basic thing, that I thought that every editor should do. Even when I was learning to do programing, in Turbo Pascal, at the age of 7, the editor was keeping indentation. Honestly, I would enable "keep" mode by default and be done with it.

And implement backspace later, as time permits.

@jasongrout
Copy link
Member

Note that shift-tab should dedent 4 spaces. Is that a good compromise?

@ellisonbg
Copy link
Member

I am fine with shift-tab working like this, but not as a substitute for fixing the backspace bug. I have posted to the codemirror list about this issue and will keep everyone updated.

@ellisonbg
Copy link
Member

Here is the response of the CodeMirror devs:

Bind your own handler to the backspace key using onKeyEvent, and have
that check for whitespace before the cursor and remove up to four
spaces if present.

This should not be too difficult, so I think we should take this approach.

@ghost ghost assigned ellisonbg May 17, 2011
@ellisonbg
Copy link
Member

@certik: I have implemented autoindentation and auto-4-space-delete in the htmlnotebook branch. Could you test and confirm it is behaving as you expect?

@ellisonbg
Copy link
Member

Implemented in htmlnotebook branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants