Tab usage
I was thinking about how the tab key works and wanted your opinion on some things @dschuyler.
-
When the selection mode is none, should we just insert a tab and move the cursor to the end of it rather than indent the whole line and have the cursor at the beginning of the line?
-
When the selection mode is not none and we tab, should we keep the cursor at the current position or keep it moving to the beginning of the line?
-
Let's say that there is a colon and then a new line. The new line operator will put the cursor on an indented spot on the next line, a few spaces after the beginning of the previous line. Should we have tab jump to this position if the cursor is before this position? For example:
for x in lst:
xx|yyyyyy
If the cursor is in some position with an x, them jump to the vertical bar if a tab is inserted (all selection modes).
Good ideas. (though I'm not sure I follow the third bullet point).
- If we add tab insertion, we should also add the option to insert tabs or spaces. E.g. the coding standard I use at work requires two space indentation (and no tabs) and it's really troublesome if the editor inserts tabs. Though some other employer may require tabs and it would be great for ci_edit to work for those users as well.
On the third bullet point:
-
Would pressing tab a second time then insert a tab (i.e. if the cursor is already at the first non-whitespace character or eol)?
-
I've noticed that some editors will do something similar iiuc, with the HOME key. e.g. there are two 'home' positions. One is at the first character of the line (textBuffer.line[N][0]) and the other is at the first non-blank character (or eol). Pressing HOME repeatedly will move the cursor between the two home positions.
Yeah I think the first bullet is a good idea and the third bullet is an interesting one that I haven't heard of. I think that sounds fun to use and would like to see it implemented. Maybe I'll take it on soon if I can't find any other bugs.
As for the second bullet point, I think it logically makes sense to insert a tab the second time. I can't think of any other functions that it could have since the first tab should put the line at supposedly the correct indentation level.
What do you think backtab should do when no text is selected? Should it do a simple tab, do nothing, or have some other function? It doesn't seem exactly perfect to make it unindent the entire line when a regular tab inserts a tab at the cursor's current position.