iPhone programming tips #2

It takes ages to get to the solution of a simple problem
while the problem which might have been there for ages, may get solved in no time.


Consider this, the programmers who shift from Windows to Mac find it hard to select the whole line of code to delete or move to the beginning or end of line of the code. They have the habit of using Ctrl + End to go to end of a line and Ctrl + Home to go to the beginning of a line of code, which can’t be used on Mac.

If you are using the Mac, the key analogous to Ctrl is the “command” or the “host” key. But there is no home key or even if you are using the Windows keyboard, pressing the home/end key along with any combination of keys  just navigates you to the top or bottom of that file.

How I discovered the solution.
There would always have been a key combination for this but I don’t have this habit of learning shortcuts beforehand. I just keep using the ones I know and learn them on the fly.

Once I accidentally pressed “command” + down arrow key, and there it was, it went to the end of the line. I tried it with the “command” and up arrow as a combination and the cursor jumped to the starting of the line. Using it with shift allowed me to select the whole line in case I wanted to move or delete that line of code.

What did we learn?

“command” + ↑ – takes the cursor to the beginning of the line.

“command” + ↓ – takes the cursor to the end of the line.

“command” + shift + ↑ – select till the beginning of the line.

“command” + shift + ↓ – select till the end of the line.

Hope that would be useful.

%d bloggers like this: