Automatic column align along colons in Xcode and Objective C? - objective-c

Is there a macro or preference setting that would automatically align method parameters along the columns and colons in Xcode?
Basically a shortcut to turn this:
[object methodWithParam:theParam another:theOtherValue something:theSomethingValue else:theElseValue];
automatically into this:
[object methodWithParam:theParam
another:theOtherValue
something:theSomethingValue
else:theElseValue];
Is it possible to get this working with code completion? In other words when I tab complete a method it would automatically wrap the formatting into this style? And what about preexisting code? Can I put my caret inside a method, press a keyboard shortcut and auto format the parameters?

It has no built in support for this. See the answers in this SO question for some tips.

Related

How to move cursor to Vue methods, computeds, data quickly in VS Code?

I already tried using the symbol explorer in VSCode (CTRL+P then write #). It allows me to jump to data (because it's a method) but it won't jump to normal properties like "computed:" or "methods:"?
This would be useful when eg. I look at my component and think "Aha! I need to add a computed, so let's jump to computeds". I could just CTRL+F but this sometimes doesn't work if another variable or comment has 'computed' in its name
Currently, you can
use Ctrl+R to open Go To Symbol in Editor,
then enter some words like data, computed or methods and etc.,
then press Enter
The cursor would be moved to the selected symbol. Tested in Win10/v1.48.2
The easiest way how to do that is probably using Bookmarks extension.
I am using them and also I haven't find a better way how to solve same problem as you have.

Intellij: Highlight current block of code

I was wondering if it is possible to highlight the block of code you are working on in Intellij Idea.
There was a similar question here: Is there a way to highlight the currently active code block in Visual Studio 2010? .
So what I mean is that if you have clicked into e.g. a method or a while loop... ,the background of the whole block becomes a bit lighter or whatever.
There's already one such feature, but it's more subtle, in the form of a vertical line inside the left gutter... I can't recall whether it's enabled by default or not, but you can activate it by File -> Settings -> Editor -> General, scroll to the Highlight on Caret Movement section (about half of the page).
I looked around for a while but I have not yet found a way to change its appearance to match your description, although I personally prefer this less intrusive highlight than having all the background changed.
P.S. Not sure this is relevant or useful to you, but there was a plugin I tried a while ago called CodeGlance which offered a scrollable-map of the class:
I don't know when this feature was implemented. As of 2021, if you double click anywhere in the scope ( but not on text ), Intellij selects the current block of code ( text within two curly braces ).

Proper tab correction of objective-c in xcode

In matlab if you highlight a section of code and press cmd+i on mac it corrects all the indentation.
Is there a similar command for xcode? Say I have a for loop inside a while loop inside a method, yet each line is flush on the left, can I highlight it all and get the tabbing fixed?
Yes, you can do that in Xcode as well - default shortcut for that is ctrl+I
It is control + i for Xcode.
Also select the code and right-click and Structure

Creating code hints in XCode [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to create documentation for instance variable and methods in Xcode?
Eclipse-based editors such as PDT and Eclipse allow you to automatically add code hints for your custom code by using a special commenting syntax. Is there anyway you can add these code hints to your custom code in XCode?
I think you're looking for the code snippet library. The shortcut key is [control][option][command]2
The code snippet library will appear in the lower-right corner of the window.
You can select some code on your screen and drag it to the Code Snippet Library. This will create a new code snippet called "My Code Snippet" which will likely appear at the bottom of the list. You can single click the new snippet to view it in a pop-up. From there, you can click the edit button to make the snippet more useful.
For place-holders, use <# text #>. For example, <#height#> would produce a placeholder labeled height.
Use the field called "Completion Shortcut" for the text you want to type in order to activate the snippet.
When you're done editing the snippet, click the done button and start typing your Completion Shortcut text to test it out.

How can replace the string [Foo alloc]<cursor> with [[Foo alloc]<cursor>]

Is there a key shortcut for this in XCode?
Can I implement an Applescript for this and run it within XCode?
You can probably do that using a script (check out the relevent piece of Xcode documentation). Also see the "Insert Text Macro" menu item…
But you might find it to be more efficient to just use the auto-correct feature. I just type "[[F", then hit my auto-correct key (bound to F5 I believe, but I've changed it), type enough of the class name for it to be selected in the autocorrect popup. Hit space, start typing alloc but let auto correct kick in. Close the brace. Start typing init, use autocorrect again.
You generally shouldn't need to create macros/scripts for something this trivial. The autocorrect, placeholders and autofill features should be all you really need.
I see that this question was asked some time ago. For anyone just stumbling on it, current versions of Xcode (3.2+) will fill in the open brackets for you as you go (what crackity_jones calls "auto-back fill"). That is, if you type
[Foo alloc]<cursor>
and then keep going...
[Foo alloc] init<cursor>
...when you type the next close bracket, Xcode will insert the corresponding open bracket in the correct place:
[[Foo alloc] init]<cursor>
Try it out. While this doesn't answer the original question directly, it does address the need.
Textmate will auto-back fill ['s for you. You can also build your xcode project from inside it as well as do thousands of other interesting things with the objective-c and other built in bundles that add functionality. It has a 30 day demo, give it a shot and see if it does what you want.