Reformatting to have method parameters in a new line - objective-c

There are so many settings in the preferences for Code->Style->Objective-C. I'm looking for the right one to reformat this line of code
SCPropertyDefinition *test = [SCPropertyDefinition definitionWithName:#"created_at" title:#"Tweeted At" type:SCPropertyTypeLabel];
to this format
SCPropertyDefinition *test = [SCPropertyDefinition definitionWithName:#"created_at"
title:#"Tweeted At"
type:SCPropertyTypeLabel];
(the point is to have the colons indention matching)
I guess the it should be in the Wrapping and Braces Tab, but I havn't found the right setting yet.
Thanks for your ideas.

The setting you are looking for is Wrapping and Braces | Method call arguments set to Chop down if long with enabled Align by colon. Note that there are separate settings for Method parameters.

It seems like as of App Code 2017.1 (perhaps earlier too) the align by colon option is not available in Swift. You can still tell App Code to chop a long argument/parameter list:

Related

How to format code to use the specified `tabSize` with the built-in formatter?

I have the following AutoHotkey script sample, notice the code is indented by a single space:
#z::
MsgBox The Win-Z hotkey was pressed.
Gosub MySubroutine
return
MySubroutine:
Sleep 1000
return
I searched through the VS Marketplace but didn't find a usable formatter extension for AHK scripts.
I've configured "editor.tabSize": 2, is there a way to format the code to use the specified tabSize with the VSCode built-in formatter?
It looks like there is an AutoHotKey Plus extension that includes formatting that seems to adhere to the Visual Studio Code built-in formatter setting for the tab size. I set my tab size to two and performed the format shortcut using the extension (Shift + Alt + F):
It seems though that certain keywords, such as return will cling to the margin, presumably because the formatter for the extension interprets this as the standard convention for AHK (in my opinion though, I like the way it looks).
This feature request is tracked here.

Disable IntelliJ splitting line comments on format

Sometimes we have long lines of Java code. Then someone comments them out temporarily, like
// String asdf = "1234-1234-1234-1234-1234-1234-1234-1234-1234_1234-1234-1234-1234-1234-1234-1234-1234-1234-1234-1234-1234-1234";
Then another developer formats the whole file, which turns it into
// String asdf = "1234-1234-1234-1234-1234-1234-1234-1234-1234_1234-1234-1234-1234-1234-1234-1234-1234-1234-1234
// -1234-1234-1234";
Then if we uncomment the code, it becomes
String asdf = "1234-1234-1234-1234-1234-1234-1234-1234-1234_1234-1234-1234-1234-1234-1234-1234-1234-1234-1234
-1234-1234-1234";
which is a syntax error in Java.
How can we avoid this? Is there a setting to disable splitting/wrapping single-line comments? I almost universally would never want to wrap a single-line comment, even if it extends a tiny bit past the defined right margin.
Do not wrap one line comments:

Is there a way to make Xcode handle brackets more intelligently?

In Xcode, if you are calling a method that takes a series of flags as an argument, when you type the right bracket character, it creates a new left bracket at the last flag, rather than at the start of the line. Is there any way to fix this?
// Type this...
someFunc withFlags:FlagA|FlagB|FlagC
// Now type a right bracket ]
someFunc withFlags:FlagA|FlagB|[FlagC ]
// It should be this:
[someFunc withFlags:FlagA|FlagB|FlagC]
Turn-On Xcode->Preferences->TextEditing->Editing->Automatically balance brackets in ObjectiveC method calls
I'm using Xcode Version 5.0.2 (5A3005). The below both of them worked fine for me.It automatically created left bracket when I closed the right one.
[self someFunc:1 Flag:YES|YES|YES];
[self someFunc:YES|YES|YES];
- (void)someFunc:(int)x Flag:(BOOL)yes
{
}
- (void)someFunc:(BOOL)yes
{
}
Here is my Xcode settings
There is no way, unfortunately. Although, filing a bug report to Apple will make this more likely to get fixed. If this behavior breaks your flow, you can always turn it off in the settings. Xcode -> Preferences... -> Text Editing -> "Automatically insert closing braces ('}')"
Type the first bracket when you start the line.
That is what you should do first.
Also you should use parentheses around your flags.

How to set IDEA better align parameters passed to some method?

I cannot make IDEA perfectly align parameters passed to some method when I break them into new line by Enter key.
Here is visually what I need. I have a method like this.
When I break parameters into new row each, it looks like this.
Even trying to align them with Tab key does not help.
You see how ugly this is, not to say it's not easy to reach such code. And all I want is too look like this:
(Note: this one I set via Space key).
I must have been doing something wrong as I can bet this can be set in IDEA. But where?
Bring up Settings panel :
Code Style > Java > Wrapping and Braces (tab)
Enable Align when multiline option in Method declaration parameters and Method call arguments
Apart from the way suggested by #Rangi Lin, also make sure that your
Code Style > Java > Keep When Reformating > Line Breaks
in your settings is also checked. Otherwise reformatting your code could realign your method params into a single line.

NSLocalizedString with empty comment?

i found this good example to use NSLocalizedString : What is the second parameter of NSLocalizedString()?
NSLocalizedString(#"Save",#"Title of the Save button in the theme saving dialog");
.
/* Title of the Save button in the theme saving dialog */
"Save" = "Save";
But what if the comment in NSLocalizedString is empty ?what does is mean? Will it automatically know where to find the translated word in localize.strings?
Thanks
The comment is reserved for the genstrings tool to help someone, who may or may not be technical, translate your localized strings into new languages.
The first parameter is the key into localizable.strings. The second parameter is a comment meant to assist in translation. It won't effect the behavior of the application at all, so it doesn't strictly matter if it's empty or nil.