Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assign to new local variable shortcut (ctrl-2 L) in android studio

I've just moved from Eclipse to android studio. One of my most used shortcut is ctrl-2 L, which will automatically assign a variable with a name and import the necessary class.

new View();

and press Ctrl-2 L, which results in:

View view = new View();

Is there a way to do it in android studio?

like image 532
Tomer Avatar asked Nov 11 '13 06:11

Tomer


People also ask

What key allows you to create local variables?

If you cursor is on the line and you hit CTRL + 1 you get a context menu to 'assign a new local variable', resulting in the following: String value = MyObject.

How do I assign a statement in eclipse?

Easiest is, hit Alt + Enter , you will be offered with a list of options, and just select "Introduce local Variable".


1 Answers

You Can See Shortcut Key in Refactor -> Extract Menu

Mac Extract Variable Use Below Shortcut:

1- ++V for local variable

2- ++F for class/field variable

3- ++C for constant

I think you must use Control+Alt key for Windows

enter image description here

like image 177
Ahmad Ronagh Avatar answered Sep 28 '22 02:09

Ahmad Ronagh