cornercorner
FeaturesPluginsDocs & SupportCommunityPartners

Bug 30147 - Rebind the Tab key to perform automatic indentation
: Rebind the Tab key to perform automatic indentation
Status: RESOLVED FIXED
: editor
-- Other --
: 3.6
: All All
: P3 with 5 votes (vote)
: 5.0
Assigned To:
:
:
:
:
:
:
  Show dependency treegraph
 
Reported: 2003-01-15 16:45 by
Modified: 2007-11-05 13:42 (History)
Issue Type: ENHANCEMENT
:


Attachments
Simple patch which implements the requested behavior (8.57 KB, patch)
2003-04-02 17:39, Torbjorn Norbye
Details | Diff
Patch migrated to NetBeans 5.0 (7.78 KB, patch)
2005-11-06 06:18, Torbjorn Norbye
Details | Diff


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2003-01-15 16:45:59
In JBuilder, the Tab key does not insert \t, it
recenters the current line (or when there is a
selection, it recenters all the lines in the
selection).

JBuilder also puts a message in the editor footer:
"Line automatically indented".

I think NetBeans should do the same.  Then it
needs a different key to insert a literal \t. I
think the editor footer message could tell the
user what it is:
  "Line automatically indented. Press Alt+t to
insert a Tab character."

See also the thread on nbusers, subject
"indentation setup", from January 2003. There are
a couple of objections to this. But instead of
continuing a discussion there, I'm filing an issue
such that the ui folks can evaluate this.
------- Comment #1 From 2003-04-02 17:38:35 -------
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.
------- Comment #2 From 2003-04-02 17:39:49 -------
Created an attachment (id=9669) [details]
Simple patch which implements the requested behavior
------- Comment #3 From 2003-04-02 17:42:12 -------
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
------- Comment #4 From 2003-04-08 18:00:04 -------
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.
------- Comment #5 From 2003-04-08 18:49:11 -------
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.
------- Comment #6 From 2003-07-17 04:43:22 -------
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)
------- Comment #7 From 2005-04-20 16:01:41 -------
*** Issue 14285 has been marked as a duplicate of this issue. ***
------- Comment #8 From 2005-06-09 18:05:54 -------
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
------- Comment #9 From 2005-11-06 06:18:24 -------
Created an attachment (id=26656) [details]
Patch migrated to NetBeans 5.0
------- Comment #10 From 2005-11-11 22:21:45 -------
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
------- Comment #11 From 2005-11-11 22:22:51 -------
marked as fixed