This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Rebind the Tab key to perform automatic indentation | ||
---|---|---|---|
Product: | editor | Reporter: | Torbjorn Norbye <tor> |
Component: | -- Other -- | Assignee: | _ ttran <ttran> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | mmetelka, trembovetski |
Priority: | P3 | ||
Version: | 3.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | ENHANCEMENT | Exception Reporter: | |
Attachments: |
Simple patch which implements the requested behavior
Patch migrated to NetBeans 5.0 |
Description
Torbjorn Norbye
2003-01-15 16:45:59 UTC
This ui problem (tab key doing the wrong thing) drives me nuts and keeps sending me back to emacs. But this week I've decided to "fly our own airplanes", so I wrote a patch to implement this issue. I'll attach it. Created attachment 9669 [details]
Simple patch which implements the requested behavior
Description of the patch: it creates a new ReindentLineAction, which it registers and binds to the Tab key. (It also changes the old insert-tab action to be bound to Control-Q [tab], as well as a commented out version of Meta-i, which are emacs bindings for it. I'm not sure what the non-emacs binding for tab should be - check JBuilder I guess.) The implementation is very straightforward - it just a copy of the code in FormatAction, but modified in two ways: - instead of using the selection begin and end points for formatting, it uses the current line - instead of moving the caret to the beginning of the line, it moves the caret to the first non-whitespace character on the line Eeek, how about having hitting tab insert a tab or replace the current selection with a tab???? I really don't like weird behaviours bound to (unmodified) keys. The behaviour of hitting tab while having a selection in the middle of a line NOT replacing the selection is already annoying enough. My point (which I made in the nbusers discussion, perhaps not in this issue report) is that tying the Tab key to indentation is not weird. Not all non-modifier keys perform self-insert; the function keys for example. JBuilder, long the market leading Java IDE, does exactly this. As does Emacs. Besides, \t's in the source code leads to various problems since the Java coding style calls for 4-space indentation, and tabs often default to 8 chars (cvs diff, vi, etc.) I'm not against allowing Tab to insert \t's, but it should be a non-default option. I believe more users will benefit from IDE managed indentation than doing on their own using Tabs. Two points here: - indention is rather broken for multiline statements, binding tab to indention would be suprising and annoying for this reason - appreciation of this is one of those things which really depends on your background (emacs vs vi vs visual studio) *** Issue 14285 has been marked as a duplicate of this issue. *** Please fix this. I'd expect that most users want the line to be properly aligned instead of adding a new tab. Certainly true in my case. Thanks, Dmitri Created attachment 26656 [details]
Patch migrated to NetBeans 5.0
Tor's patch refined and applied. The new action is bound to tab only in Emacs keymap. C-q <tab> inserts \t. Also works on selection. I also found a bug 68575. Will fix separately IDE:------------------------------------------------- IDE: [11/11/05 11:10 PM] Committing Files started Checking in editor/libsrc/org/netbeans/editor/BaseKit.java; /cvs/editor/libsrc/org/netbeans/editor/BaseKit.java,v <-- BaseKit.java new revision: 1.141; previous revision: 1.140 done Checking in editor/libsrc/org/netbeans/editor/ActionFactory.java; /cvs/editor/libsrc/org/netbeans/editor/ActionFactory.java,v <-- ActionFactory.java new revision: 1.71; previous revision: 1.70 done Checking in editor/libsrc/org/netbeans/editor/Bundle.properties; /cvs/editor/libsrc/org/netbeans/editor/Bundle.properties,v <-- Bundle.properties new revision: 1.65; previous revision: 1.64 done Checking in ide/defaults/src/org/netbeans/modules/defaults/Emacs-keybindings.xml; /cvs/ide/defaults/src/org/netbeans/modules/defaults/Emacs-keybindings.xml,v <-- Emacs-keybindings.xml new revision: 1.11; previous revision: 1.10 done IDE: [11/11/05 11:10 PM] Committing Files finished marked as fixed |