Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a keyboard shortcut in Xcode to move cursor to the first character of the current line? [duplicate]

I come from Windows world and used Visual Studio for years. When I click [Home] in Visual Studio, it means "move input cursor to the beginning of the first non-space character of the current line" (not the beginning of the line). e.g.

class Foo {
public:
    void bar();
};

In Visual Studio, if the cursor is at line void bar(); and I click [Home], the cursor will move to the front of character 'v' instead of the beginning of the line.

Is there a keyboard shortcut in Xcode?

like image 457
Alex Avatar asked Apr 04 '11 16:04

Alex


3 Answers

Have you tried Fn + ? This is the Mac equivalent of Home. You can also try + . However, these may not exhibit the exact behaviour you're after, as "move input cursor to the beginning of the first non-space character of the current line" is a custom behaviour that is implemented by the application rather than the OS (i.e., if XCode hasn't explicitly added support for this, it won't work).

like image 92
alastairs Avatar answered Nov 16 '22 23:11

alastairs


I have forever trying to find a way to do so too...

and basically you cannot. (maybe some hacking way would enable it..?)

from XCode Preference / Key Bindings search for "move to" and try everything you find. NONE of them will move cursor to first visible char of line.

XCode (and standard textboxes in OSX) seems to have similar cursor movement setup like emacs standard setup.

VIM Normal mode | emacs   | XCode          | Visual Studio | what is it
0               | Ctrl+a  | Ctrl+a  ⌘ + ←  | Home          | first char of line
$               | Ctrl+e  | Ctrl+e  ⌘ + →  | End           | last char of line
^               | <???>   | <???>          | Home          | first visible char of line

closest and fastest way you can do is move to first non-punctuation char by these key combinations: ⌘ ←, ⌥ →, ⌥ ←

however it does get little annoying when you code in objective-C where you may have a number of leading open square brackets (punctuation char).... I'd suggest move your hand to your pointing device (eg. mouse) for that situation...

Please emacs/xcode masters, flame me for my lack of knowledge emacs cannot move cursor to first visible char of line in one key combination!! (I am dying to know I am wrong!)

like image 39
coder9t99 Avatar answered Nov 16 '22 22:11

coder9t99


Most Mac OS X text boxes will allow you to use Emacs key bindings Ctrl + E for beginning of sentence, etc.(hence the remapping of cut,copy,paste to use the command key). Also as stated above Cmd + will get you to the beginning of the line.

like image 2
JMFR Avatar answered Nov 16 '22 22:11

JMFR