How to Surround Selected Codes with Quote or Brace in Android Studio

By default, when you highlight a word or a phrase then press quote, the highlighted words are replaced by quotes. That’s how Android Studio works. There are 2 solutions to insert quotes or braces.

Live template

Surround live template can be used to insert any symbols or characters to both sides of selected text. Braces surrounding can be called by default with B abbreviation so there is no need to add a new template. Access Settings > Editor > Live Template and add a new template within surround group for quote. The template’s content should be “$SELECTION$”.

Then you can apply this template via Live Template popup menu by pressing Ctrl+Alt+T or Ctrl+Alt+J.

Smart Keys

Using Smart Keys is a simple and faster. Access Settings > Editor > General > Smart Keys and check “Surround selection on typing quote or brace”. Android Studio then auto insert quote or brace when you type them when highlight texts.