News for hackers. Stuff that matters.
Re:Write code for the web - Apple doesn't care about you, Mr... by romanovcode on Sunday February 04, 2024 @10:29AM (#39250947)
I still can't figure out how to format on save in Xcode. Or format in general?
Re:Write code for the web - Apple doesn't care about you, Mr... by DelightOne on Sunday February 04, 2024 @10:38AM (#39251040)
Format with this integration: https://github.com/ruiaureliano/X-SwiftFormat

Then make CMD+s the shortcut.

Re:Write code for the web - Apple doesn't care about you, Mr... by andrekandre on Sunday February 04, 2024 @11:01AM (#39251292)
thats great (i use swift format plugin myself) but really apple should provide these features not 3rd parties and ideally format while typing not just save
Re:Write code for the web - Apple doesn't care about you, Mr... by Someone on Sunday February 04, 2024 @10:33AM (#39250993)
> Or format in general?

I use the workaround of Command-A, command-X, command-V aka “Select All, Cut, Paste”.

Unfortunately that loses cursor position in the file and gives you a free newline at the end of your content.

Re:Write code for the web - Apple doesn't care about you, Mr... by noSyncCloud on Sunday February 04, 2024 @11:27AM (#39251600)
You're supposed to end your document with a newline. That's a POSIX standard.
Re:Write code for the web - Apple doesn't care about you, Mr... by mdaniel on Sunday February 04, 2024 @12:23PM (#39252222)
I don't mean this as snark, I'm genuinely interested: do you have a phrase I can search for or a link to that? I don't think I've ever heard that before but I would love to start citing it
Re:Write code for the web - Apple doesn't care about you, Mr... by Someone on Sunday February 04, 2024 @02:31PM (#39253536)
Because otherwise, files can contain characters that aren’t on any of its lines.

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1...:

“3.206 Line

A sequence of zero or more non- <newline> characters plus a terminating <newline> character.”

That’s consistent with:

  > echo test | wc
         1       1       5
  > echo -n test | wc
         0       1       4
Re:Write code for the web - Apple doesn't care about you, Mr... by andoma on Sunday February 04, 2024 @02:21PM (#39253451)
Me too. Feels like I have an uphill battle with this at $dayjob. Would be nice with some ammo for the showdowns.
Re:Write code for the web - Apple doesn't care about you, Mr... by Someone on Sunday February 04, 2024 @11:52AM (#39251883)
I know, but if your file already ends in one, it adds a second one, if it already ends in two, it adds a third one, etc.