Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Add semicolon and goto new line" hotkey

I'm a beginner in android programing. I use Android Studio (v0.8.9). Here is problem a tackled with:

Ctrl + Shift + Enter adds a semicolon and moves the caret to the end of the line, Shift + Enter does not a add semicolon and moves the caret to a new line. Question is how to make InteliJ IDEA add semicolon to the end of current line and move caret to the new line by pressing, say, Shift + Enter?

like image 913
Sergii Avatar asked Sep 10 '14 15:09

Sergii


4 Answers

Pressing Ctrl + Shift + Enter twice should do the job. You can record a keyboard macro that does it, and assign a custom shortcut to it.

like image 172
Peter Gromov Avatar answered Nov 18 '22 10:11

Peter Gromov


It's 2020 now and Ctrl + Shift + Enter shortcut now works as expected in Android Studio (tested 4.1.1). MacOS version should have a different modifier, but should be almostly same.

like image 30
ttimasdf Avatar answered Nov 18 '22 10:11

ttimasdf


Another way to get the IDE to add semicolon If you have code completion enabled you can press tab on your code snippet, then press shift+enter to go to a new line.

For example:
1. type sout and press tab.
2. the editor fills in System.out.println($CursorHere);
3. type "foobar" where the cursor appears.
4. press shift enter and you'll be taken to a new line.

like image 1
MTen Avatar answered Nov 18 '22 10:11

MTen


You can customise your shortcuts in preferences - > Keymap

Set custom shortcut

Edit or add new shorts cut is very easy from here.

like image 1
Sumit Patel Avatar answered Nov 18 '22 10:11

Sumit Patel