A bit of Code Completion Kung Fu
Some time ago we had a post about basics of code completion with AppCode, so I’ll assume that you already are familiar with it, and that you have ⌃Space and ⌃⇧Space shortcuts at your fingertips. You know how and when to invoke completion, but let me ask you a question. What do you do when you’ve found the required item in the list? Wait, here’s a wild guess, you press Enter. Right? That works, of course. AppCode inserts the selected element at the caret position. However, there is a number of scenarios when AppCode can do more than that, look deeper into your code structure and in the end save even more time for you.
In short, there are two more ways to finish code completion: you can either use Tab, or one of the symbols like a dot, colon, semicolon or a bracket. What difference does it make? Let me just show you some examples.
Finishing with Tab
It doesn’t matter which type of completion you use, the finishing logic described here will work the same way for both of them. When you press Tab instead of Enter on the selected item, instead of just inserting the element, AppCode overwrites the following expression with the selected option, taking the structure around into account.
For instance, let’s say you have a method call that you want to replace with another method call:
Here’s what happens when you use Enter:
Note, that selected item is simply inserted, and you still need to clean up what’s left from the previous call. But here’s what you’ll get by pressing Tab:
Less manual work, and more intelligent result. Basically, completion with Tab is a structural completion. Try it out on selectors, variables, methods to get a better feeling of it.
Finishing with a symbol
Here, by symbol I mean a dot, a colon, a bracket… Finishing completion of an element with one of those characters also completes the statement.
So you invoke code completion:
If you press Enter, you get what you were aiming for, but the statement isn’t finished yet:
If you press a dot, having an item selected in the list, you jump to the next completion suggestion:
You can also finish completion with a semicolon to complete the statement at once:
If you play a bit with these various ways of completing your code, I believe you’ll find more uses for them, and also get a feeling when they work better for you.
There are more code completion (and not only) tricks to come, so stay tuned!
Subscribe to Blog updates
Writing Code Documentation in AppCode
Code documentation can save you a lot of time and headaches. On the other hand, it also takes a lot of effort to write and maintain it. In this article, we will look at the AppCode features that can help you create detailed and well-structured code documentation and keep it updated after code refact…
Polish Your Code with AppCode’s Inspections and Intentions
AppCode is constantly analyzing your code to find parts that can be improved. It provides sets of code inspections and intention actions for each supported language for this exact purpose. Inspections locate unused or redundant code, syntax errors, probable bugs, spelling mistakes, obsolete or redun…
Navigation in AppCode
Navigating through files and source code, especially in complex projects, can eat up a lot of time, which is why it is essential to learn how to move around quickly in your IDE. AppCode provides plenty of navigation features that can help you move faster. In this blog post, we’ll take a look at some…
Server-side Swift in AppCode
In this short article we’ll take a look at various AppCode features that are useful for server-side Swift development, as now you can open standalone SPM projects in AppCode on macOS. Check out and open the project On the Welcome screen, click the Get from VCS button and enter the address of the Fe…