Xcode auto completion to replace function call name - how to drop placeholders? - xcode

Xcode's auto-completion is often getting in my way by giving me argument placeholders when I already have them. Here's an example:
I want to change that second MoveToPoint to AddLineToPoint, so I delete part of the name, and hit control + space for the Show Completions command. I get something like:
You see the annoyance. I tab complete the name, but now I have to delete the 3 arguments, the commas, and the parentheses. This kind of thing annoys me and throws off my flow when writing code.
Ideally I'd like a way to delete these placeholders with one command, or have a separate auto-complete command, so along with Show Completions (control + space), I could bind something like Show Completions without Placeholders. Does anyone know how to do that?

XCode does support this actually. They call it "Select Previous Completion". Check it out here (under Code Sense).
You essentially just hit ⌃> (hold control and press >) for XCode to choose your previous completion. It think it only works well though if the new method you're calling takes the same number of arguments as the previous one.
Hope this helps

Related

Visual Studio 2013 IntelliSense Subword Navigation and Completion

I am curious if VS2013 has the possibility to make it's intellisense auto-complete a little more effective.
I am used to have classes like MyClassInCamelCase and MyClassAgainInCamelCase even MyClassYetAgainInCamelCase. The way intellisense works for me is that I type My and I get a list of the 3 possible classes that match this word. But things will be a lot easier if I could make it like a command prompt and hit some special key that will autocomplete the word until the next CamelCase word, so I could get "My", then "MyClass" and then the next character I type can define a unique word (or just hit ; for example and auto-complete the current selected word on the list).
Also, the possibility to navigate between CamelCase words will be of great help.
Does anyone knows if this is a hidden feature or something? Or if there are external plug-ins that can make this possible?
This might not directly answer your question, but note that with camel-cased type names, you can do better than to start typing the beginning of a type name (My):
Typing an enclosed part of the name:
Again will suggest MyClassAgainInCamelCase and MyClassYetAgainInCamelCase.
Yet will suggest just MyClassYetAgainInCamelCase.
Typing just the capitalized letters:
MCY will suggest MyClassYetAgainInCamelCase.
Both of these shortcuts can be combined, btw.
I think the hotkey combination is Ctrl + Space to open Intelisense, than Tab, Enter or Space to insert.
There is a complete word option in the Intelisense settings, check if that's toggled on.

A new language, how to auto-complete in windows vim?

I'm using Gvim in windows.
Normally, when we type some character then press Ctrl-n, vim will show some tag, but those tags just includes words which have been pre-typed in the current file.
Now, I need it working in a new language, and show the tag which has been defined in other files.
So, I create a new \\.ctags for this new language, and generate tags file by exuberant-ctags.
I can choose a function in current file, then press Ctrl-] to jump to the function definition, but this function was define in the other files. It is working very well.
I don't know how to make it show the tags which are generated by ctags when I type some character.
Please help me. Thanks very much.
My English is poor, I hope you can understand what I said.
CTRL-N is just the default completion (which completes from a variety of sources, including the open buffers and also the tags database). There are many more specialized completions (all starting with CTRL-X), among them tags completion, triggered via CTRL-X CTRL-], see :help i_CTRL-X_CTRL-]. If you've correctly configured the 'tags' option (so your tags database is found) and tags jumps do work, just start using that.
Some languages / filetypes also define a language-specific completion (for language keywords etc.), usually via the 'omnifunc' option and triggered by CTRL-X CTRL-O. You could write such yourself, too.

can I edit Xcode code completion suggestions?

I love the code completion in Xcode, it saves me a lot of typing work. Also, it confirms my code is probably error-free in real time. However, to me, some code suggestions are disturbing. For example, when I type else after an if-statement, Xcode suggests this:
else {
statement
}
I'd like to change this to just:
else
statement
Because, I quite often just want to use one line of code there, and adding curled brackets goes much faster than removing them. The other annoying thing is the fact that using such a suggestion takes the return key, while a new line does as well. So, if I would want to use my preferred way as shown above, I would first have to press the escape key in order to stop Xcode suggesting it, and then press the return key. Not a real pain, but I think it's unnecessary.
There are some other code suggestions which I would like to change, but I think I have made my point already. Is there a way to change these code suggestions? I know Apple doesn't provide an easy way within Xcode itself, but I'm willing to dive into the finder for the file with suggestions and change it manually. Thanks!
in your example, it would work to add a space after typing else. Doing that removes the brace suggestion and you can just hit enter.

few vim autoinserts for ruby needed

I want to try the following things in vim insert mode:
to have closing bracket/parenthesis inserted (after the cursor) every time I type the opening one
to have #{} inserted whenever I type # inside "" (optionally, inside %() too)
I know it is possible, but my competence in this part of vim does not even reach the self-starter level.
This script will do the first one (auto inserting the closing bracket and placing the cursor between the brackets.)
lh-brackets helps define brackets related mappings. It also provides a few functions aimed at defining context-sensitive mappings and abbreviations (see Map4TheseContext).
If in ruby %() is associated to a syntax highlighting, Map4TheseContext will also solve your last request. If not, you'll have to play with searchpair() to detect the current context. Let me know if you have troubles to come up with a working solution.

Using macros without the escape key

I am trying to use the a macro in xcode.
I type in a then hit escape and select it.
This is annoying because I have to hit page up 5 times to get to the a.
Is there a different key combination that will just let me use the a as typed without having to select it?
Have you changed your XCode defaults? I'm using 3.1.4 and I don't have to hit page up. Here are my exact key presses:
a
escape
enter
I can also hit escape first and start typing the macro name.
Edit: Argh! Your demon has infiltrated my XCode! ;) If I auto-complete some things, they become sticky as the new starting "a" macro--I can't even backspace and type "a" to use the first "a" macro. Each file has it's own persistent memory too, so switching files changes the default. Using a method or property or any other parsed symbol seems to have priority over the macros so the default will never go back to the initial "a" macro once you auto-complete a parsed symbol.
Pretty weird bug. I must not have seen it because I don't use macros much.
The only way I found to fix this is to change the "a" macro to some other auto-complete such as "ai". That way when you type "a" "escape", typing "i" next will select the macro you want even if there's a bad sticky default.
Start with this reference http://mcdevzone.com/2009/04/09/useful-xcode-tricks/
Then edit "~/Library/Application Support/Developer/Shared/Xcode/Specifications/TextMacros.xctxtmacro/Contents/Resources/ObjectiveC.xctxtmacro" and change the "CompletionPrefix = a;" to some other prefix.
When you restart XCode, the new prefix will work in place of the old "a" macro.

Resources