Block comments, key bindings and feeling foolish!

Do you ever get stuck on something, and then when you work out what you were doing wrong you feel a bit foolish?

I was just thinking – it would be much more convenient if there was a keyboard shortcut to block comment some code. I know that with the keyboard shortcut Command-/ you can automatically generate single line comments:

BlockComment3.gif

But what I was after was a keyboard shortcut to generate block comments. Strangely this capability seems to be missing from Xcode, but I happened upon an Xcode Source Editor extension called BlockComment that seemed to do the job.

So – after installing BlockComment, I went into the Key Bindings tab in Xcode preferences, double clicked on the BlockComment binding to add a keyboard shortcut, and… nothing.BlockComment1.gif

I closed Xcode, opened Xcode – did it again and… nothing. I’ve done this before, how strange! Read up on key bindings, hmm… yes I seem to be doing the right thing, what could be going wrong?

Then I watched a video and that was when I felt foolish.

Of course! You can’t just click anywhere on the line – you need to click in the key field on the right!

BlockComment2.gif

Sometimes when you work out what you were doing wrong, it all seems so obvious!

So! Things I’ve learned today

FIRST – When customizing a keyboard shortcut in Key bindings – click in the Key field!

SECONDBlockComment – works quite well, I recommend!

BlockComment4.gif

THIRD – sometimes there’s no substitute for a video tutorial!

You might think that’s a strange sentiment for a book author, but as it turns out I’m currently working on a video course to accompany the book!

Of course, everyone has a preference for how to learn. Maybe you like books coz you can read them on the train. Maybe you prefer videos as you find it easier to learn visually. Either way, you have a choice now when learning iOS development with Swift.

Combo.jpg

You can check out the book “iOS Development with Swift” here.

Or – you can check out the livevideo course “iOS Development with Swift in Motion” here. The video course is currently in the Manning early access program, and new Units will be put out regularly.

You can use both together or independently, depending on your preference!

Good luck with them, and enjoy block commenting your code with keyboard shortcuts!

iOS development with Swift - book: https://manning.com/books/ios-development-with-swift video course: https://www.manning.com/livevideo/ios-development-with-swift-lv

Tagged with: ,
Posted in Swift

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: