I don't know about you, but I can't work in a code editor that doesn't show me line numbers. Xcode is no different. Line numbers in Xcode make it easy to quickly navigate to a piece of code. This is especially useful if you are browsing a pull request on GitHub and quickly want to jump to a code snippet in Xcode. In this quick tip, you learn how to show line numbers in Xcode and how to quickly jump to a line of code.
Show Line Numbers in Xcode
Fire up Xcode and create a project or a playground. A code editor without line numbers doesn't feel right. Agreed?
There is no menu item or keyboard shortcut to toggle line numbers in Xcode. We need to bring up Xcode's preferences window. Choose Preferences... from the Xcode menu and select the Text Editing tab. We are interested in the Display section. The first option is the option we are looking for, Line numbers. Checking the checkbox displays line numbers in the gutter of the code editor.
This is much better.
Even though it is possible to define a key binding or keyboard shortcut for most Xcode commands, this doesn't apply to showing or hiding line numbers in Xcode's code editor.
Jump to Line Number
A feature I use dozens of time a day is jumping to a line of code in Xcode's code editor. Select Jump to Line in "FILENAME"... from Xcode's Navigate menu and enter a line number. If you don't want to lift your fingers from the keyboard, I suggest you remember the keyboard short, Command + L.