Search code examples
androidandroid-studioide

How to paste on separate line in Android Studio?


In Sublime Text 3 and Resharper, when you paste(Ctrl+V) a copied line(Ctrl+C) on the caret location, it pastes the content on a new line above the line with the caret and adds a carriage return at the end.

For example, if I copy the entire line Bar bar = new Bar(); and try to paste on the line bar.getDrinks();, I get the following output:

Bar bar = new Bar();
bar.getDrinks();

But in Android Studio the same operation results in the following:

bar.getDrinks(); Bar bar = new Bar();

provided the caret was after the semicolon in bar.getDrinks(); code.

Does anyone know how to fix this in Android Studio?


Solution

  • The solutions I could find were to either:

    1. (2 key press combinations) Go to the beginning of the current line, and paste the line copied, or

    2. (4 key press combinations) Go to the line above -> Press Enter -> Paste the line copied -> Delete the line below the line copied.

    I prefer to use the 1st method.