Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make tab indent the current line

I'm using IntelliJ IDEA to write Java and finding the default Tab behaviour (inserting a tab at the cursor position) quite annoying. I want it to behave like Shift-Tab.

Shift-Tab de-indents the cursor line if there is no selection, or every line in the selection if there is one, regardless of the cursor's position on the line. I tried to make Tab behave the same way by changing the keymap settings: I unbound the Tab key from Editor ActionsTab so that it'd perform EditIndent Selection. But that only makes it indent the selection: if there's no selection, pressing Tab now does nothing.

It appears that the de-indent action for Shift-Tab is actually Editor ActionsUnindent Selection, but there's no corresponding action for indenting.

How can I make the Tab key indent the current line (increase the indent by one stop) if there is no selection?

like image 978
Dan Hulme Avatar asked Aug 25 '13 14:08

Dan Hulme


3 Answers

  1. Remove the keyboard shortcut from "Tab"
  2. Add "Tab" as a keyboard shortcut to "Indent Line or Selection". When the dialog pops up asking you to "Leave" or "remove", click "Leave".

This works on at least IDEA 14+ but I haven't tested it on anything before that

like image 78
tddmonkey Avatar answered Oct 24 '22 12:10

tddmonkey


You can press Ctrl+W which selects the nearest item to the cursor and then press Tab to indent or Shift+Tab to unindent the current line.

like image 35
fracz Avatar answered Oct 24 '22 14:10

fracz


Not exactly what you need, but you can try Code | Auto-Indent Lines. There is also a known bug about the difference in the selection indent/unindent behavior.

like image 41
CrazyCoder Avatar answered Oct 24 '22 13:10

CrazyCoder