AppCode Code Completion. 101

Posted on by Maria Khalusova

It’s quite hard to imagine a code editor that doesn’t have code completion nowadays. Seriously, who wants a tool that doesn’t understand what you’re about to do and cannot give you a hand with it?

Given all IntelliJ IDEA and ReSharper history, it would be weird to say the least if AppCode couldn’t be as helpful for Objective-С developers as mentioned tools are for Java and .NET guys. After all, coding assistance was always one of the distinguishing features of JetBrains’ products.

If you’re used to Xcode, you may find it strange at first to discover that there are different code completion types in AppCode: basic (⌃Space), smart type(⌃⇧Space) and some others which are of no interest for us right now. Why would we need to have 2 major completions separated and what’s the difference between them?

Basic code completion (⌃Space) is the one everyone expects to be there in a decent IDE: complete the name of any class, method or a variable instantly as you type.
Quite natural, isn’t it? However AppCode is way more intelligent than just that, though we wouldn’t want anyone to think that we know better:) That’s why all the smart completions are separated from the basic ones – you got them when you need them, but there’s no pressure.

Smart Type completion (⌃⇧Space) analyzes the context you are currently working with and prepares the list of choices for you. It filters the list of methods and variables to match the expected expression type. For example, it can suggest a constructor or factory method of a class expected:

This things you may have already known, but here are a few magic tricks!

Trick #1: CamelHumps
To complete your code even faster, and to limit the search suggestions to exactly what you need, just use “CamelHumps”: AppCode identifies parts of compound names composed according to CamelCase, where each part starts with a capital letter.

#1 Class completion with CamelHumps

#2 Method completion with CamelHumps

Trick #2: Autocomplete block arguments
Smart completion (⌃⇧Space) can also make your life easier by completing block arguments:

Trick #3: Smarter completion
Actually there’s more intelligence hidden behind both completion kinds that can be revealed by pressing the corresponding shortcut twice.

  • Press ⌃Space for basic completion twice, and AppCode will find not yet imported symbols (for example, functions) and add the import for you.
  • If Smart Type completion didn’t suggest you anything, try pressing the same shortcut (⌃⇧Space) one more time: AppCode will look up values of the expected type which can be retrieved through a chained method call.

Trick #4: Let AppCode worry about square brackets

When calling a method on a variable you can forget about square brackets – AppCode will add them automatically.


Have you tried AppCode already? What other AppCode features you’d like us to cover?

Stay tuned!

Comments below can no longer be edited.

13 Responses to AppCode Code Completion. 101

  1. Joram Barrez says:

    May 22, 2012

    Thanks for writing this down … I hadn’t found smart completion yet! Awesome!

    • Maria Khalusova says:

      May 23, 2012

      You’re welcome!

  2. Nik says:

    June 4, 2012

    Awesome tips, thanks! Block completion in particular is incredibly useful!

    I think I still want smart and normal completion to be combined into one shortcut though. A “take your best guess as to what I want to do” shortcut. Eclipse works this way and I got used to it – it doesn’t distinguish between “smart” and normal completion. I am not sure it does as much as IntelliJ though – and it clearly doesn’t do anything in Obj-C 😉

    Maybe I’ll get used to thinking in terms of smart and non-smart completions one day – it kind of makes sense the way it’s described here. “There is no pressure” – not sure I am buying it. I am already telling the IDE I want some sort of completion, why not do them both for me. I don’t think it’s a CPU issue, AppCode seems plenty fast.

    I mean – conceptually, basic completion _also_ analyzes the context, doesn’t it? I can see how it’s a completely different thing in the implementation. But using this feature, it’s kind of the same thing.

    Don’t want to complain by the way I am incredibly happy smart completion is there, block completion is just fantastic, and in general AppCode pulls iOS development from the dark ages and into the not-so-new-but-still-novel-at-Apple world of power IDEs.

    • Nik says:

      June 4, 2012

      I mean… what would I do without AppCode? Pulling my hair on a daily basis, probably.

  3. Marcello Stanisci says:

    August 18, 2012

    I would like to see Code folding for all “if” and “for” and “switch” statements automatically

  4. A bit of Code Completion Kung Fu | JetBrains AppCode Blog says:

    September 12, 2012

    […] time ago we had a post about basics of code completion with AppCode, so I’ll assume that you already familiar with […]

  5. Dmitry Viktorov says:

    January 9, 2014

    How to show interface methods & properties suggestions list? AppCode will show it only when I begin typing method name. But I would like to expand all list. ⌃Space and ⌃⇧Space don’t show this list.

    • Anton Makeev says:

      January 13, 2014

      Ctrl+Space/Ctrl+Shift+Space in the default keymap layout should work (check the keymap in Preferences | Keymap).
      If they don’t please file a bug report in the tracker with some details and code snippets.

  6. Mark says:

    May 13, 2014

    Is there any way to have AppCode incrementally complete non-abiguous code while not completing the whole thing? For example, if I type in “[self tab” (while editing a UITableViewController, for example), I’ll get a whole lot of methods that start with “tableView:”. If I’m looking for “tableView:estimatedHeightForRowAtIndexPath:”, I have to scroll down the list using the arrow keys or mouse. This is very awkward because the list is really long.

    What’s worse, though what I’m shown are entries like “tableView:cellForRowAtIndexPath”, if I continue typing “tableView:”, I loose the completion list and I actually can’t type the other parts of the names of the methods (i.e estimatedHeightForRowAtIndexPath).

    What I would like is to be able to hit tab, or some other key, have it complete as much as is it can so:

    [self tab would give me: [self tableView

    I could then type “:es” and I’d get a list of the 3 methods who’s signature starts with “tableView:es”.

    Does that make sense? The code completion in JetBrains products is so powerful that thought there must be a way to do this, but I haven’t been able to find it.

    • Anastasia Kazakova says:

      May 15, 2014

      The thing is that you don’t need to type ‘:’. You can use Camel Hump completion (read our post about completion: and type tVcFR to look for “tableView:cellForRowAtIndexPath”, for example.

      • Mark says:

        May 19, 2014

        I’m not sure how to respond. It does work and is pretty amazing. I do find it much more confusing than the Emacs style of “keep banging on tab to incrementally complete”, though I’ll give it a try.

        I find it quite unnatural, because I’m essentially typing in gibberish, in that, I type in a prefix, see the list, scan through it for the next camel case then start typing from there.

        I’m amazed that AppCode (and I assume other JetBrains products) does not support the “complete as much as you can” style of completion. I really hope that you add it in the future as I’m not sure I can get used to way it works currently.

        • Anton Makeev says:

          May 25, 2014

          Mark, adding ‘common-prefix’ behavior will make completion inconsistent and conflicting with ‘camel-hump’ completion. You can check the discussion in this request and leave your thought and suggestions there.

      • Mark says:

        May 19, 2014

        One more thing I forgot to ask about: what do you do when the substring is not camel case?

        I think having the complete as much as you can solves all cases and should be implemented, at least as an option, that can be bound to tab.


Subscribe to product updates