Top 10 AppCode Editor Actions

Marianna Kononenko

In this blog post, we will talk about the most useful basic AppCode actions that can help you edit code much faster. Once you learn these shortcuts and start using them regularly, you’ll come to realize just how much time they save you.

1. Duplicate a line

Place the caret at the line you want to duplicate and press ⌘D:

Duplicate a line

2. Delete a line

To delete a line at the caret, press ⌘⌫:

Delete a line

3. Expand/shrink the selection

In AppCode, you can select code fragments based on their structure using the Extend Selection (⌥↑) and Shrink Selection (⌥↓) actions:

Expand and shrink the selection

In our example, the code selection is extended in the following order: the return key word, the return statement, the method body, the whole method, and then the extension. In a plain text file, the selection starts with a word and then extends to a sentence, paragraph, and so on.

4. Move a line or statement up and down

To move a line or selection up or down, press ⌥⇧↑ or ⌥⇧↓:

Move a line

To move a statement (function, variable declaration, condition, etc.) up or down, use the ⇧⌘↑ and ⇧⌘↓ shortcuts:

Move a statement

5. Paste from clipboard history

Did you copy something but forget to paste it? You can find the missing entry in the clipboard history by pressing ⇧⌘V:

Copy from history

In the dialog that opens, select the entry that you want to paste and click Paste. To paste the text without formatting, click Paste as Plain Text.

6. Toggle between upper and lower case

Press ⇧⌘U to toggle selected characters between upper and lower case:

Toggle between upper and lower case

When you apply this action to CamelCase text, AppCode will convert it all to lowercase.

7. Set multiple carets

You can set multiple carets by holding ⇧⌥ and then edit code in several places simultaneously:

Multiple carets

Another way to set multiple carets is to enable column selection mode. To do this, either activate column selection mode by pressing ⇧⌘8 or just hold and move the mouse cursor.

Column selection mode

You can also place carets at all occurrences of the selected symbol in the open file by pressing ⌃⌘G. Press ⇧⌃G to deselect occurrences one by one, and ⌃G to extend the selection. To remove the selection, press Esc or point the cursor somewhere else.

Select all occurrences

8. Surround with

Using the Surround With action (⌥⌘T), you can surround an arbitrary region with a code construct that you can set in a custom live template.

For example, you can add templates for wrapping SwiftUI code into the VStack or HStack elements in AppCode | Preferences | Editor | Live Templates:

Surround live template

There are detailed instructions on how to do this in Create a surround live template.

When a template with the $SELECTION$ keyword is added, it will be available from the Surround With popup that opens when you press ⌥⌘T:

Surround with a live template

9. Reformat code

To fix the formatting of the code in the file you’re working in, press ⌥⌘L:

Reformat code

The IDE will reformat your code according to the rules specified in AppCode | Preferences | Editor | Code Style. Read more on code formatting in Reformat and rearrange code.

10. Code folding

To fold classes and methods you can either use the +/- icons in the gutter or press ⌘-/⌘+. To collapse or expand all code fragments, press ⇧⌘-/⇧⌘+.

Fold code

You can make any code block that is surrounded by {curly brackets} collapsible. To do this, place the cursor anywhere between the brackets and press ⇧⌘.:

Fold a code block

Moreover, it is possible to collapse and expand a custom code selection by pressing ⌘.:

Fold selection

There are many other useful actions available in the AppCode editor. To learn more about this topic, read the Work with source code section of our documentation and check out the IDE Features Trainer plugin. If you are familiar with the Xcode shortcuts for similar actions, you don’t have to learn the new ones – just switch to the Xcode keymap in AppCode | Preferences | Keymap.

That’s all for today. Share your favorite shortcuts with us here in the comments!

The AppCode Team

Subscribe

Subscribe to product updates