Move to beginning of text in Xcode












41















I know I can bind keys to "Move to beginning of line", but this ignores the indentation.



What I'm looking for is to move to the beginning of text on a line, so that:



CGRect example = CGRectMake(view.frame.origin.x,
view.frame.origin.y,|


pressing a key will move the cursor to the beginning of the "view" word in this example (char | is cursor).



It is extremely annoying that currently I have to press 3 commands to get to the beginning of the text when inside a code block (cmd <-, opt ->, opt <-).










share|improve this question

























  • I'm looking for the same thing! All the Java-based IDE's do this when you are in the middle or at the end of the line: 1st CMD+LEFT_ARROW takes you to beginning of first word on line, 2nd one takes you to actual beginning of line, 3rd time back to first word, and so on. It makes it so fast and easy to hop around text, I wish Xcode 4 would do the same thing!!

    – jpswain
    Oct 11 '11 at 20:38


















41















I know I can bind keys to "Move to beginning of line", but this ignores the indentation.



What I'm looking for is to move to the beginning of text on a line, so that:



CGRect example = CGRectMake(view.frame.origin.x,
view.frame.origin.y,|


pressing a key will move the cursor to the beginning of the "view" word in this example (char | is cursor).



It is extremely annoying that currently I have to press 3 commands to get to the beginning of the text when inside a code block (cmd <-, opt ->, opt <-).










share|improve this question

























  • I'm looking for the same thing! All the Java-based IDE's do this when you are in the middle or at the end of the line: 1st CMD+LEFT_ARROW takes you to beginning of first word on line, 2nd one takes you to actual beginning of line, 3rd time back to first word, and so on. It makes it so fast and easy to hop around text, I wish Xcode 4 would do the same thing!!

    – jpswain
    Oct 11 '11 at 20:38
















41












41








41


13






I know I can bind keys to "Move to beginning of line", but this ignores the indentation.



What I'm looking for is to move to the beginning of text on a line, so that:



CGRect example = CGRectMake(view.frame.origin.x,
view.frame.origin.y,|


pressing a key will move the cursor to the beginning of the "view" word in this example (char | is cursor).



It is extremely annoying that currently I have to press 3 commands to get to the beginning of the text when inside a code block (cmd <-, opt ->, opt <-).










share|improve this question
















I know I can bind keys to "Move to beginning of line", but this ignores the indentation.



What I'm looking for is to move to the beginning of text on a line, so that:



CGRect example = CGRectMake(view.frame.origin.x,
view.frame.origin.y,|


pressing a key will move the cursor to the beginning of the "view" word in this example (char | is cursor).



It is extremely annoying that currently I have to press 3 commands to get to the beginning of the text when inside a code block (cmd <-, opt ->, opt <-).







xcode






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 '11 at 4:19







lkraider

















asked Mar 9 '11 at 3:49









lkraiderlkraider

2,74512027




2,74512027













  • I'm looking for the same thing! All the Java-based IDE's do this when you are in the middle or at the end of the line: 1st CMD+LEFT_ARROW takes you to beginning of first word on line, 2nd one takes you to actual beginning of line, 3rd time back to first word, and so on. It makes it so fast and easy to hop around text, I wish Xcode 4 would do the same thing!!

    – jpswain
    Oct 11 '11 at 20:38





















  • I'm looking for the same thing! All the Java-based IDE's do this when you are in the middle or at the end of the line: 1st CMD+LEFT_ARROW takes you to beginning of first word on line, 2nd one takes you to actual beginning of line, 3rd time back to first word, and so on. It makes it so fast and easy to hop around text, I wish Xcode 4 would do the same thing!!

    – jpswain
    Oct 11 '11 at 20:38



















I'm looking for the same thing! All the Java-based IDE's do this when you are in the middle or at the end of the line: 1st CMD+LEFT_ARROW takes you to beginning of first word on line, 2nd one takes you to actual beginning of line, 3rd time back to first word, and so on. It makes it so fast and easy to hop around text, I wish Xcode 4 would do the same thing!!

– jpswain
Oct 11 '11 at 20:38







I'm looking for the same thing! All the Java-based IDE's do this when you are in the middle or at the end of the line: 1st CMD+LEFT_ARROW takes you to beginning of first word on line, 2nd one takes you to actual beginning of line, 3rd time back to first word, and so on. It makes it so fast and easy to hop around text, I wish Xcode 4 would do the same thing!!

– jpswain
Oct 11 '11 at 20:38














9 Answers
9






active

oldest

votes


















44














There's no standard way to accomplish it in XCode, so I've written an XCode plugin implementing this feature:



https://github.com/insanehunter/XCode4_beginning_of_line



Under the hood it overrides XCode's source editor keyboard action dispatch method and implements beginning/ending of line jumps in enhanced way.



Hope it helped.






share|improve this answer



















  • 3





    works perfectly!

    – lkraider
    Nov 28 '11 at 15:32











  • iHunter, you are a gentleman and a scholar. Thank you!

    – Mike Clark
    May 17 '12 at 17:24











  • @MikeClark Oh, thank you! Your words are the best motivation for me ever!

    – iHunter
    May 18 '12 at 12:38











  • Really good work! This was driving me crazy...

    – Simon Epskamp
    Jul 5 '12 at 11:20






  • 2





    @physicalattraction Yes, works perfectly. In case of troubles try downloading latest version from github and building it again - there are Xcode compatibility UDIDs added with each major Xcode release.

    – iHunter
    Apr 22 '15 at 14:36



















8














Use option + to jump across entire words.



(That means, hold the option while pressing the left arrow key)






share|improve this answer


























  • Yes, I am aware, but this will not move to the beginning of the line as I asked, it will move word by word.

    – lkraider
    Mar 9 '11 at 3:59













  • @lkraider: I don't see a way to do this in XCode (or OS X in general, since that's where most of the cursor movement shortcuts are inherited from). XCode 3.2 keyboard shortcuts.

    – Matt Ball
    Mar 9 '11 at 4:07











  • Yes, I was afraid of that. On that note, there doesn't seem to be any difference between the beginning of line and beginning of paragraph, both bindings do the same thing.

    – lkraider
    Mar 9 '11 at 4:25



















7














As of 7.3 (not sure when it was added), Xcode seems to have turned this on by default. Cmd-left in the Key Bindings preference pane is now bound to "Move to Beginning of Text."



Personally, this drives me bonkers, so I've changed it back to "Move to Beginning of Line." But for people who want this behavior, it's good to know that there's now a built-in way to get it.



If you've copied your Key Bindings Set, you may not be seeing the new behavior yet. If not, just search for "beginning" in the Key Bindings preferences and adjust them to your liking.






share|improve this answer





















  • 1





    Just tested this in Xcode 8.2 and it works great. Make sure to delete the key bindings for Cmd+Left and Home and and the Shift+Cmd+Left and Shift+Home bindings for Move to Left End of Line Extending Selection and reassign those to Move to Beginning of Text Extending Selection. Really weird defaults, Apple.

    – Jared Updike
    May 29 '18 at 17:18



















5














I'm using Xcode 7.2 and was able to make my own macro to automate those 3 commands you mentioned above (cmd <-, opt ->, opt <-). You can edit the IDETextKeyBindingSet.plist file which defines all the key-bindings to add your own.



Mine was located at /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist



Add the following to create your own macro



<key>Custom Keys</key>
<dict>
<key>Move to non-whitespace beginning of line</key>
<string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
</dict>


Relaunch xcode and in your Preferences > Key Bindings tab, search for your custom macro and set it to cmd <-. Now it will run those 3 commands and effectively moves your cursor to the beginning of the text in the line.






share|improve this answer
























  • That's great to know! Added to mine too. Just have to remember to edit that file when updating Xcode.

    – lkraider
    Jan 14 '16 at 16:36











  • Thanks, this works for everything except for when the line starts with a symbol (like [). The cursor is positioned right after the symbol, like: [|NSString ....]

    – Radu Cugut
    Feb 9 '16 at 12:40













  • Thanks, this solution, I think, is the best one.

    – chih-chun chan
    Mar 3 '16 at 9:35











  • I get an authentication error when I try to update this file, and I'm too new to Mac / Xcode development to know how to edit the file with admin authentication. Could you perhaps give me a suggestion?

    – RenniePet
    Feb 6 '17 at 10:51



















3














Actually, there is a faster and simpler way to achieve this as Mac OS supports some Emacs (or Unix) keybindings quite well.



You can use Ctrl-a to jump to the beginning of a line. Which means, hold 'Ctrl' key and press 'a' on keyboard.



For your more information, it is also handy to use
Ctrl-e: jump to the end of a line
Ctrl-n: move to next line
Ctrl-p: move to previous line



What's more, these fast keys can be used in terminal and text fields such as this StackOverflow answer editor on Mac OS, too.



Hope that helps.






share|improve this answer
























  • These are really useful, but don't seem to work for me in Xcode 7.2 ? Either way, they work as Home/End usually in other apps, which means they would ignore indentation too.

    – lkraider
    Dec 10 '15 at 20:18











  • As far as I know and all the Mac I've used, these keybindings work well. Besides, I don't quite understand "ignore indentation too". Do you mean it doesn't work when there are indentations?

    – junhan
    Dec 10 '15 at 23:45













  • "ignore indentation too" -> the same as I mean in the original question, where it should move to the beginning of text, not the beginning of the line.

    – lkraider
    Dec 11 '15 at 13:30



















2














I don't have an exact solution, just one slight improvement for Xcode 4. You could set up a keyboard mapping for "Move Expression Left" (Xcode prefs > Key Bindings), which is a little more than Opt ←:



s = [NSString string] |


if | is the cursor position, pressing a "Move Expression Left" keystroke will bring it to the beginning of the expression on the left of it, so in that case before "[NSString". Opt ← will only move before "string".



(Side note: I do see an action command called "Move to Left end of line" and another one called "Move to beginning of line." To my experience, these do exactly the same behavior in Xcode 4.0.2: this looks to me like a bug, unless I'm missing something.)






share|improve this answer



















  • 1





    Interesting, could be useful, not sure. I actually find it curious they go to the trouble of implementing these complex expression parsing cursor movements, but manage to keep the simple stuff out.

    – lkraider
    May 30 '11 at 23:18



















1














Tested on XCode 10:



Step1: Open the file located in the next path by a text editor



 /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist


Add the next elements to the end of the file:



<key>Sublime Commands</key>
<dict>
<key>Cut Current Line</key>
<string>selectLine:, cut:</string>
<key>Copy Current Line</key>
<string>selectLine:, copy:</string>
<key>Duplicate Current Line</key>
<string>selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine:</string>
<key>Delete Current Line</key>
<string>selectLine:, deleteToEndOfLine:, moveToEndOfLine:</string>
<key>Move To First Char In Line</key>
<string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
</dict>


The previous last key 'Move To First Char In Line' will do your request, but I mentioned also other keys.



Now save the file.



Step2: Close XCode and reopen it.



Step3: Navigate to keybinding in xcode preferences then assign your shortcut.



XCode -> Preferences -> Key Bindings
Then search for 'Move To First Char In Line' and assign your shortcut.



enter image description here






share|improve this answer


























  • Awesome! Tested working on Xcode 8 as well

    – lkraider
    Jan 4 at 21:11



















0














It seems that the simplest way, as already mentioned is



1) Go to the beginning of the line (Cmd + left arrow key)



2) Jump to right word (Alt + right arrow key)



3) Jump to left word (Alt + left arrow key)



Unfortunately (Alt + left arrow key) and (Alt + right arrow key) ignores comments, brackets, etc and therefore the method above will not always work. If this is not a problem, then there is also one solution for the BetterTouchTool users. One can create a sequence of actions (commands) that will be called one after another and assign it to Home button. To do so, open the preferences, go to Keyboard tab, Add new shortcut and assign Home button to the (Cmd + left arrow key). Then click Assign additional actions twice, first one for the (Alt + right arrow key) and the second one for the (Alt + left arrow) key commands.



Hopefully this helps.






share|improve this answer

































    0














    In this Xcode extension, Linex, the feature Line Beginning can move to the first non-whitespace character in a line, and also toggle between that and the real beginning.



    Works for Xcode 9, perhaps Xcode 8.






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f5241092%2fmove-to-beginning-of-text-in-xcode%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      9 Answers
      9






      active

      oldest

      votes








      9 Answers
      9






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      44














      There's no standard way to accomplish it in XCode, so I've written an XCode plugin implementing this feature:



      https://github.com/insanehunter/XCode4_beginning_of_line



      Under the hood it overrides XCode's source editor keyboard action dispatch method and implements beginning/ending of line jumps in enhanced way.



      Hope it helped.






      share|improve this answer



















      • 3





        works perfectly!

        – lkraider
        Nov 28 '11 at 15:32











      • iHunter, you are a gentleman and a scholar. Thank you!

        – Mike Clark
        May 17 '12 at 17:24











      • @MikeClark Oh, thank you! Your words are the best motivation for me ever!

        – iHunter
        May 18 '12 at 12:38











      • Really good work! This was driving me crazy...

        – Simon Epskamp
        Jul 5 '12 at 11:20






      • 2





        @physicalattraction Yes, works perfectly. In case of troubles try downloading latest version from github and building it again - there are Xcode compatibility UDIDs added with each major Xcode release.

        – iHunter
        Apr 22 '15 at 14:36
















      44














      There's no standard way to accomplish it in XCode, so I've written an XCode plugin implementing this feature:



      https://github.com/insanehunter/XCode4_beginning_of_line



      Under the hood it overrides XCode's source editor keyboard action dispatch method and implements beginning/ending of line jumps in enhanced way.



      Hope it helped.






      share|improve this answer



















      • 3





        works perfectly!

        – lkraider
        Nov 28 '11 at 15:32











      • iHunter, you are a gentleman and a scholar. Thank you!

        – Mike Clark
        May 17 '12 at 17:24











      • @MikeClark Oh, thank you! Your words are the best motivation for me ever!

        – iHunter
        May 18 '12 at 12:38











      • Really good work! This was driving me crazy...

        – Simon Epskamp
        Jul 5 '12 at 11:20






      • 2





        @physicalattraction Yes, works perfectly. In case of troubles try downloading latest version from github and building it again - there are Xcode compatibility UDIDs added with each major Xcode release.

        – iHunter
        Apr 22 '15 at 14:36














      44












      44








      44







      There's no standard way to accomplish it in XCode, so I've written an XCode plugin implementing this feature:



      https://github.com/insanehunter/XCode4_beginning_of_line



      Under the hood it overrides XCode's source editor keyboard action dispatch method and implements beginning/ending of line jumps in enhanced way.



      Hope it helped.






      share|improve this answer













      There's no standard way to accomplish it in XCode, so I've written an XCode plugin implementing this feature:



      https://github.com/insanehunter/XCode4_beginning_of_line



      Under the hood it overrides XCode's source editor keyboard action dispatch method and implements beginning/ending of line jumps in enhanced way.



      Hope it helped.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 27 '11 at 12:26









      iHunteriHunter

      5,75733356




      5,75733356








      • 3





        works perfectly!

        – lkraider
        Nov 28 '11 at 15:32











      • iHunter, you are a gentleman and a scholar. Thank you!

        – Mike Clark
        May 17 '12 at 17:24











      • @MikeClark Oh, thank you! Your words are the best motivation for me ever!

        – iHunter
        May 18 '12 at 12:38











      • Really good work! This was driving me crazy...

        – Simon Epskamp
        Jul 5 '12 at 11:20






      • 2





        @physicalattraction Yes, works perfectly. In case of troubles try downloading latest version from github and building it again - there are Xcode compatibility UDIDs added with each major Xcode release.

        – iHunter
        Apr 22 '15 at 14:36














      • 3





        works perfectly!

        – lkraider
        Nov 28 '11 at 15:32











      • iHunter, you are a gentleman and a scholar. Thank you!

        – Mike Clark
        May 17 '12 at 17:24











      • @MikeClark Oh, thank you! Your words are the best motivation for me ever!

        – iHunter
        May 18 '12 at 12:38











      • Really good work! This was driving me crazy...

        – Simon Epskamp
        Jul 5 '12 at 11:20






      • 2





        @physicalattraction Yes, works perfectly. In case of troubles try downloading latest version from github and building it again - there are Xcode compatibility UDIDs added with each major Xcode release.

        – iHunter
        Apr 22 '15 at 14:36








      3




      3





      works perfectly!

      – lkraider
      Nov 28 '11 at 15:32





      works perfectly!

      – lkraider
      Nov 28 '11 at 15:32













      iHunter, you are a gentleman and a scholar. Thank you!

      – Mike Clark
      May 17 '12 at 17:24





      iHunter, you are a gentleman and a scholar. Thank you!

      – Mike Clark
      May 17 '12 at 17:24













      @MikeClark Oh, thank you! Your words are the best motivation for me ever!

      – iHunter
      May 18 '12 at 12:38





      @MikeClark Oh, thank you! Your words are the best motivation for me ever!

      – iHunter
      May 18 '12 at 12:38













      Really good work! This was driving me crazy...

      – Simon Epskamp
      Jul 5 '12 at 11:20





      Really good work! This was driving me crazy...

      – Simon Epskamp
      Jul 5 '12 at 11:20




      2




      2





      @physicalattraction Yes, works perfectly. In case of troubles try downloading latest version from github and building it again - there are Xcode compatibility UDIDs added with each major Xcode release.

      – iHunter
      Apr 22 '15 at 14:36





      @physicalattraction Yes, works perfectly. In case of troubles try downloading latest version from github and building it again - there are Xcode compatibility UDIDs added with each major Xcode release.

      – iHunter
      Apr 22 '15 at 14:36













      8














      Use option + to jump across entire words.



      (That means, hold the option while pressing the left arrow key)






      share|improve this answer


























      • Yes, I am aware, but this will not move to the beginning of the line as I asked, it will move word by word.

        – lkraider
        Mar 9 '11 at 3:59













      • @lkraider: I don't see a way to do this in XCode (or OS X in general, since that's where most of the cursor movement shortcuts are inherited from). XCode 3.2 keyboard shortcuts.

        – Matt Ball
        Mar 9 '11 at 4:07











      • Yes, I was afraid of that. On that note, there doesn't seem to be any difference between the beginning of line and beginning of paragraph, both bindings do the same thing.

        – lkraider
        Mar 9 '11 at 4:25
















      8














      Use option + to jump across entire words.



      (That means, hold the option while pressing the left arrow key)






      share|improve this answer


























      • Yes, I am aware, but this will not move to the beginning of the line as I asked, it will move word by word.

        – lkraider
        Mar 9 '11 at 3:59













      • @lkraider: I don't see a way to do this in XCode (or OS X in general, since that's where most of the cursor movement shortcuts are inherited from). XCode 3.2 keyboard shortcuts.

        – Matt Ball
        Mar 9 '11 at 4:07











      • Yes, I was afraid of that. On that note, there doesn't seem to be any difference between the beginning of line and beginning of paragraph, both bindings do the same thing.

        – lkraider
        Mar 9 '11 at 4:25














      8












      8








      8







      Use option + to jump across entire words.



      (That means, hold the option while pressing the left arrow key)






      share|improve this answer















      Use option + to jump across entire words.



      (That means, hold the option while pressing the left arrow key)







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Mar 8 '12 at 19:48

























      answered Mar 9 '11 at 3:52









      Matt BallMatt Ball

      283k76557634




      283k76557634













      • Yes, I am aware, but this will not move to the beginning of the line as I asked, it will move word by word.

        – lkraider
        Mar 9 '11 at 3:59













      • @lkraider: I don't see a way to do this in XCode (or OS X in general, since that's where most of the cursor movement shortcuts are inherited from). XCode 3.2 keyboard shortcuts.

        – Matt Ball
        Mar 9 '11 at 4:07











      • Yes, I was afraid of that. On that note, there doesn't seem to be any difference between the beginning of line and beginning of paragraph, both bindings do the same thing.

        – lkraider
        Mar 9 '11 at 4:25



















      • Yes, I am aware, but this will not move to the beginning of the line as I asked, it will move word by word.

        – lkraider
        Mar 9 '11 at 3:59













      • @lkraider: I don't see a way to do this in XCode (or OS X in general, since that's where most of the cursor movement shortcuts are inherited from). XCode 3.2 keyboard shortcuts.

        – Matt Ball
        Mar 9 '11 at 4:07











      • Yes, I was afraid of that. On that note, there doesn't seem to be any difference between the beginning of line and beginning of paragraph, both bindings do the same thing.

        – lkraider
        Mar 9 '11 at 4:25

















      Yes, I am aware, but this will not move to the beginning of the line as I asked, it will move word by word.

      – lkraider
      Mar 9 '11 at 3:59







      Yes, I am aware, but this will not move to the beginning of the line as I asked, it will move word by word.

      – lkraider
      Mar 9 '11 at 3:59















      @lkraider: I don't see a way to do this in XCode (or OS X in general, since that's where most of the cursor movement shortcuts are inherited from). XCode 3.2 keyboard shortcuts.

      – Matt Ball
      Mar 9 '11 at 4:07





      @lkraider: I don't see a way to do this in XCode (or OS X in general, since that's where most of the cursor movement shortcuts are inherited from). XCode 3.2 keyboard shortcuts.

      – Matt Ball
      Mar 9 '11 at 4:07













      Yes, I was afraid of that. On that note, there doesn't seem to be any difference between the beginning of line and beginning of paragraph, both bindings do the same thing.

      – lkraider
      Mar 9 '11 at 4:25





      Yes, I was afraid of that. On that note, there doesn't seem to be any difference between the beginning of line and beginning of paragraph, both bindings do the same thing.

      – lkraider
      Mar 9 '11 at 4:25











      7














      As of 7.3 (not sure when it was added), Xcode seems to have turned this on by default. Cmd-left in the Key Bindings preference pane is now bound to "Move to Beginning of Text."



      Personally, this drives me bonkers, so I've changed it back to "Move to Beginning of Line." But for people who want this behavior, it's good to know that there's now a built-in way to get it.



      If you've copied your Key Bindings Set, you may not be seeing the new behavior yet. If not, just search for "beginning" in the Key Bindings preferences and adjust them to your liking.






      share|improve this answer





















      • 1





        Just tested this in Xcode 8.2 and it works great. Make sure to delete the key bindings for Cmd+Left and Home and and the Shift+Cmd+Left and Shift+Home bindings for Move to Left End of Line Extending Selection and reassign those to Move to Beginning of Text Extending Selection. Really weird defaults, Apple.

        – Jared Updike
        May 29 '18 at 17:18
















      7














      As of 7.3 (not sure when it was added), Xcode seems to have turned this on by default. Cmd-left in the Key Bindings preference pane is now bound to "Move to Beginning of Text."



      Personally, this drives me bonkers, so I've changed it back to "Move to Beginning of Line." But for people who want this behavior, it's good to know that there's now a built-in way to get it.



      If you've copied your Key Bindings Set, you may not be seeing the new behavior yet. If not, just search for "beginning" in the Key Bindings preferences and adjust them to your liking.






      share|improve this answer





















      • 1





        Just tested this in Xcode 8.2 and it works great. Make sure to delete the key bindings for Cmd+Left and Home and and the Shift+Cmd+Left and Shift+Home bindings for Move to Left End of Line Extending Selection and reassign those to Move to Beginning of Text Extending Selection. Really weird defaults, Apple.

        – Jared Updike
        May 29 '18 at 17:18














      7












      7








      7







      As of 7.3 (not sure when it was added), Xcode seems to have turned this on by default. Cmd-left in the Key Bindings preference pane is now bound to "Move to Beginning of Text."



      Personally, this drives me bonkers, so I've changed it back to "Move to Beginning of Line." But for people who want this behavior, it's good to know that there's now a built-in way to get it.



      If you've copied your Key Bindings Set, you may not be seeing the new behavior yet. If not, just search for "beginning" in the Key Bindings preferences and adjust them to your liking.






      share|improve this answer















      As of 7.3 (not sure when it was added), Xcode seems to have turned this on by default. Cmd-left in the Key Bindings preference pane is now bound to "Move to Beginning of Text."



      Personally, this drives me bonkers, so I've changed it back to "Move to Beginning of Line." But for people who want this behavior, it's good to know that there's now a built-in way to get it.



      If you've copied your Key Bindings Set, you may not be seeing the new behavior yet. If not, just search for "beginning" in the Key Bindings preferences and adjust them to your liking.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Apr 18 '16 at 21:24

























      answered Apr 18 '16 at 21:18









      Nick K9Nick K9

      722620




      722620








      • 1





        Just tested this in Xcode 8.2 and it works great. Make sure to delete the key bindings for Cmd+Left and Home and and the Shift+Cmd+Left and Shift+Home bindings for Move to Left End of Line Extending Selection and reassign those to Move to Beginning of Text Extending Selection. Really weird defaults, Apple.

        – Jared Updike
        May 29 '18 at 17:18














      • 1





        Just tested this in Xcode 8.2 and it works great. Make sure to delete the key bindings for Cmd+Left and Home and and the Shift+Cmd+Left and Shift+Home bindings for Move to Left End of Line Extending Selection and reassign those to Move to Beginning of Text Extending Selection. Really weird defaults, Apple.

        – Jared Updike
        May 29 '18 at 17:18








      1




      1





      Just tested this in Xcode 8.2 and it works great. Make sure to delete the key bindings for Cmd+Left and Home and and the Shift+Cmd+Left and Shift+Home bindings for Move to Left End of Line Extending Selection and reassign those to Move to Beginning of Text Extending Selection. Really weird defaults, Apple.

      – Jared Updike
      May 29 '18 at 17:18





      Just tested this in Xcode 8.2 and it works great. Make sure to delete the key bindings for Cmd+Left and Home and and the Shift+Cmd+Left and Shift+Home bindings for Move to Left End of Line Extending Selection and reassign those to Move to Beginning of Text Extending Selection. Really weird defaults, Apple.

      – Jared Updike
      May 29 '18 at 17:18











      5














      I'm using Xcode 7.2 and was able to make my own macro to automate those 3 commands you mentioned above (cmd <-, opt ->, opt <-). You can edit the IDETextKeyBindingSet.plist file which defines all the key-bindings to add your own.



      Mine was located at /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist



      Add the following to create your own macro



      <key>Custom Keys</key>
      <dict>
      <key>Move to non-whitespace beginning of line</key>
      <string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
      </dict>


      Relaunch xcode and in your Preferences > Key Bindings tab, search for your custom macro and set it to cmd <-. Now it will run those 3 commands and effectively moves your cursor to the beginning of the text in the line.






      share|improve this answer
























      • That's great to know! Added to mine too. Just have to remember to edit that file when updating Xcode.

        – lkraider
        Jan 14 '16 at 16:36











      • Thanks, this works for everything except for when the line starts with a symbol (like [). The cursor is positioned right after the symbol, like: [|NSString ....]

        – Radu Cugut
        Feb 9 '16 at 12:40













      • Thanks, this solution, I think, is the best one.

        – chih-chun chan
        Mar 3 '16 at 9:35











      • I get an authentication error when I try to update this file, and I'm too new to Mac / Xcode development to know how to edit the file with admin authentication. Could you perhaps give me a suggestion?

        – RenniePet
        Feb 6 '17 at 10:51
















      5














      I'm using Xcode 7.2 and was able to make my own macro to automate those 3 commands you mentioned above (cmd <-, opt ->, opt <-). You can edit the IDETextKeyBindingSet.plist file which defines all the key-bindings to add your own.



      Mine was located at /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist



      Add the following to create your own macro



      <key>Custom Keys</key>
      <dict>
      <key>Move to non-whitespace beginning of line</key>
      <string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
      </dict>


      Relaunch xcode and in your Preferences > Key Bindings tab, search for your custom macro and set it to cmd <-. Now it will run those 3 commands and effectively moves your cursor to the beginning of the text in the line.






      share|improve this answer
























      • That's great to know! Added to mine too. Just have to remember to edit that file when updating Xcode.

        – lkraider
        Jan 14 '16 at 16:36











      • Thanks, this works for everything except for when the line starts with a symbol (like [). The cursor is positioned right after the symbol, like: [|NSString ....]

        – Radu Cugut
        Feb 9 '16 at 12:40













      • Thanks, this solution, I think, is the best one.

        – chih-chun chan
        Mar 3 '16 at 9:35











      • I get an authentication error when I try to update this file, and I'm too new to Mac / Xcode development to know how to edit the file with admin authentication. Could you perhaps give me a suggestion?

        – RenniePet
        Feb 6 '17 at 10:51














      5












      5








      5







      I'm using Xcode 7.2 and was able to make my own macro to automate those 3 commands you mentioned above (cmd <-, opt ->, opt <-). You can edit the IDETextKeyBindingSet.plist file which defines all the key-bindings to add your own.



      Mine was located at /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist



      Add the following to create your own macro



      <key>Custom Keys</key>
      <dict>
      <key>Move to non-whitespace beginning of line</key>
      <string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
      </dict>


      Relaunch xcode and in your Preferences > Key Bindings tab, search for your custom macro and set it to cmd <-. Now it will run those 3 commands and effectively moves your cursor to the beginning of the text in the line.






      share|improve this answer













      I'm using Xcode 7.2 and was able to make my own macro to automate those 3 commands you mentioned above (cmd <-, opt ->, opt <-). You can edit the IDETextKeyBindingSet.plist file which defines all the key-bindings to add your own.



      Mine was located at /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist



      Add the following to create your own macro



      <key>Custom Keys</key>
      <dict>
      <key>Move to non-whitespace beginning of line</key>
      <string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
      </dict>


      Relaunch xcode and in your Preferences > Key Bindings tab, search for your custom macro and set it to cmd <-. Now it will run those 3 commands and effectively moves your cursor to the beginning of the text in the line.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jan 14 '16 at 7:49









      internet-nicointernet-nico

      1,3571615




      1,3571615













      • That's great to know! Added to mine too. Just have to remember to edit that file when updating Xcode.

        – lkraider
        Jan 14 '16 at 16:36











      • Thanks, this works for everything except for when the line starts with a symbol (like [). The cursor is positioned right after the symbol, like: [|NSString ....]

        – Radu Cugut
        Feb 9 '16 at 12:40













      • Thanks, this solution, I think, is the best one.

        – chih-chun chan
        Mar 3 '16 at 9:35











      • I get an authentication error when I try to update this file, and I'm too new to Mac / Xcode development to know how to edit the file with admin authentication. Could you perhaps give me a suggestion?

        – RenniePet
        Feb 6 '17 at 10:51



















      • That's great to know! Added to mine too. Just have to remember to edit that file when updating Xcode.

        – lkraider
        Jan 14 '16 at 16:36











      • Thanks, this works for everything except for when the line starts with a symbol (like [). The cursor is positioned right after the symbol, like: [|NSString ....]

        – Radu Cugut
        Feb 9 '16 at 12:40













      • Thanks, this solution, I think, is the best one.

        – chih-chun chan
        Mar 3 '16 at 9:35











      • I get an authentication error when I try to update this file, and I'm too new to Mac / Xcode development to know how to edit the file with admin authentication. Could you perhaps give me a suggestion?

        – RenniePet
        Feb 6 '17 at 10:51

















      That's great to know! Added to mine too. Just have to remember to edit that file when updating Xcode.

      – lkraider
      Jan 14 '16 at 16:36





      That's great to know! Added to mine too. Just have to remember to edit that file when updating Xcode.

      – lkraider
      Jan 14 '16 at 16:36













      Thanks, this works for everything except for when the line starts with a symbol (like [). The cursor is positioned right after the symbol, like: [|NSString ....]

      – Radu Cugut
      Feb 9 '16 at 12:40







      Thanks, this works for everything except for when the line starts with a symbol (like [). The cursor is positioned right after the symbol, like: [|NSString ....]

      – Radu Cugut
      Feb 9 '16 at 12:40















      Thanks, this solution, I think, is the best one.

      – chih-chun chan
      Mar 3 '16 at 9:35





      Thanks, this solution, I think, is the best one.

      – chih-chun chan
      Mar 3 '16 at 9:35













      I get an authentication error when I try to update this file, and I'm too new to Mac / Xcode development to know how to edit the file with admin authentication. Could you perhaps give me a suggestion?

      – RenniePet
      Feb 6 '17 at 10:51





      I get an authentication error when I try to update this file, and I'm too new to Mac / Xcode development to know how to edit the file with admin authentication. Could you perhaps give me a suggestion?

      – RenniePet
      Feb 6 '17 at 10:51











      3














      Actually, there is a faster and simpler way to achieve this as Mac OS supports some Emacs (or Unix) keybindings quite well.



      You can use Ctrl-a to jump to the beginning of a line. Which means, hold 'Ctrl' key and press 'a' on keyboard.



      For your more information, it is also handy to use
      Ctrl-e: jump to the end of a line
      Ctrl-n: move to next line
      Ctrl-p: move to previous line



      What's more, these fast keys can be used in terminal and text fields such as this StackOverflow answer editor on Mac OS, too.



      Hope that helps.






      share|improve this answer
























      • These are really useful, but don't seem to work for me in Xcode 7.2 ? Either way, they work as Home/End usually in other apps, which means they would ignore indentation too.

        – lkraider
        Dec 10 '15 at 20:18











      • As far as I know and all the Mac I've used, these keybindings work well. Besides, I don't quite understand "ignore indentation too". Do you mean it doesn't work when there are indentations?

        – junhan
        Dec 10 '15 at 23:45













      • "ignore indentation too" -> the same as I mean in the original question, where it should move to the beginning of text, not the beginning of the line.

        – lkraider
        Dec 11 '15 at 13:30
















      3














      Actually, there is a faster and simpler way to achieve this as Mac OS supports some Emacs (or Unix) keybindings quite well.



      You can use Ctrl-a to jump to the beginning of a line. Which means, hold 'Ctrl' key and press 'a' on keyboard.



      For your more information, it is also handy to use
      Ctrl-e: jump to the end of a line
      Ctrl-n: move to next line
      Ctrl-p: move to previous line



      What's more, these fast keys can be used in terminal and text fields such as this StackOverflow answer editor on Mac OS, too.



      Hope that helps.






      share|improve this answer
























      • These are really useful, but don't seem to work for me in Xcode 7.2 ? Either way, they work as Home/End usually in other apps, which means they would ignore indentation too.

        – lkraider
        Dec 10 '15 at 20:18











      • As far as I know and all the Mac I've used, these keybindings work well. Besides, I don't quite understand "ignore indentation too". Do you mean it doesn't work when there are indentations?

        – junhan
        Dec 10 '15 at 23:45













      • "ignore indentation too" -> the same as I mean in the original question, where it should move to the beginning of text, not the beginning of the line.

        – lkraider
        Dec 11 '15 at 13:30














      3












      3








      3







      Actually, there is a faster and simpler way to achieve this as Mac OS supports some Emacs (or Unix) keybindings quite well.



      You can use Ctrl-a to jump to the beginning of a line. Which means, hold 'Ctrl' key and press 'a' on keyboard.



      For your more information, it is also handy to use
      Ctrl-e: jump to the end of a line
      Ctrl-n: move to next line
      Ctrl-p: move to previous line



      What's more, these fast keys can be used in terminal and text fields such as this StackOverflow answer editor on Mac OS, too.



      Hope that helps.






      share|improve this answer













      Actually, there is a faster and simpler way to achieve this as Mac OS supports some Emacs (or Unix) keybindings quite well.



      You can use Ctrl-a to jump to the beginning of a line. Which means, hold 'Ctrl' key and press 'a' on keyboard.



      For your more information, it is also handy to use
      Ctrl-e: jump to the end of a line
      Ctrl-n: move to next line
      Ctrl-p: move to previous line



      What's more, these fast keys can be used in terminal and text fields such as this StackOverflow answer editor on Mac OS, too.



      Hope that helps.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Dec 10 '15 at 7:15









      junhanjunhan

      7219




      7219













      • These are really useful, but don't seem to work for me in Xcode 7.2 ? Either way, they work as Home/End usually in other apps, which means they would ignore indentation too.

        – lkraider
        Dec 10 '15 at 20:18











      • As far as I know and all the Mac I've used, these keybindings work well. Besides, I don't quite understand "ignore indentation too". Do you mean it doesn't work when there are indentations?

        – junhan
        Dec 10 '15 at 23:45













      • "ignore indentation too" -> the same as I mean in the original question, where it should move to the beginning of text, not the beginning of the line.

        – lkraider
        Dec 11 '15 at 13:30



















      • These are really useful, but don't seem to work for me in Xcode 7.2 ? Either way, they work as Home/End usually in other apps, which means they would ignore indentation too.

        – lkraider
        Dec 10 '15 at 20:18











      • As far as I know and all the Mac I've used, these keybindings work well. Besides, I don't quite understand "ignore indentation too". Do you mean it doesn't work when there are indentations?

        – junhan
        Dec 10 '15 at 23:45













      • "ignore indentation too" -> the same as I mean in the original question, where it should move to the beginning of text, not the beginning of the line.

        – lkraider
        Dec 11 '15 at 13:30

















      These are really useful, but don't seem to work for me in Xcode 7.2 ? Either way, they work as Home/End usually in other apps, which means they would ignore indentation too.

      – lkraider
      Dec 10 '15 at 20:18





      These are really useful, but don't seem to work for me in Xcode 7.2 ? Either way, they work as Home/End usually in other apps, which means they would ignore indentation too.

      – lkraider
      Dec 10 '15 at 20:18













      As far as I know and all the Mac I've used, these keybindings work well. Besides, I don't quite understand "ignore indentation too". Do you mean it doesn't work when there are indentations?

      – junhan
      Dec 10 '15 at 23:45







      As far as I know and all the Mac I've used, these keybindings work well. Besides, I don't quite understand "ignore indentation too". Do you mean it doesn't work when there are indentations?

      – junhan
      Dec 10 '15 at 23:45















      "ignore indentation too" -> the same as I mean in the original question, where it should move to the beginning of text, not the beginning of the line.

      – lkraider
      Dec 11 '15 at 13:30





      "ignore indentation too" -> the same as I mean in the original question, where it should move to the beginning of text, not the beginning of the line.

      – lkraider
      Dec 11 '15 at 13:30











      2














      I don't have an exact solution, just one slight improvement for Xcode 4. You could set up a keyboard mapping for "Move Expression Left" (Xcode prefs > Key Bindings), which is a little more than Opt ←:



      s = [NSString string] |


      if | is the cursor position, pressing a "Move Expression Left" keystroke will bring it to the beginning of the expression on the left of it, so in that case before "[NSString". Opt ← will only move before "string".



      (Side note: I do see an action command called "Move to Left end of line" and another one called "Move to beginning of line." To my experience, these do exactly the same behavior in Xcode 4.0.2: this looks to me like a bug, unless I'm missing something.)






      share|improve this answer



















      • 1





        Interesting, could be useful, not sure. I actually find it curious they go to the trouble of implementing these complex expression parsing cursor movements, but manage to keep the simple stuff out.

        – lkraider
        May 30 '11 at 23:18
















      2














      I don't have an exact solution, just one slight improvement for Xcode 4. You could set up a keyboard mapping for "Move Expression Left" (Xcode prefs > Key Bindings), which is a little more than Opt ←:



      s = [NSString string] |


      if | is the cursor position, pressing a "Move Expression Left" keystroke will bring it to the beginning of the expression on the left of it, so in that case before "[NSString". Opt ← will only move before "string".



      (Side note: I do see an action command called "Move to Left end of line" and another one called "Move to beginning of line." To my experience, these do exactly the same behavior in Xcode 4.0.2: this looks to me like a bug, unless I'm missing something.)






      share|improve this answer



















      • 1





        Interesting, could be useful, not sure. I actually find it curious they go to the trouble of implementing these complex expression parsing cursor movements, but manage to keep the simple stuff out.

        – lkraider
        May 30 '11 at 23:18














      2












      2








      2







      I don't have an exact solution, just one slight improvement for Xcode 4. You could set up a keyboard mapping for "Move Expression Left" (Xcode prefs > Key Bindings), which is a little more than Opt ←:



      s = [NSString string] |


      if | is the cursor position, pressing a "Move Expression Left" keystroke will bring it to the beginning of the expression on the left of it, so in that case before "[NSString". Opt ← will only move before "string".



      (Side note: I do see an action command called "Move to Left end of line" and another one called "Move to beginning of line." To my experience, these do exactly the same behavior in Xcode 4.0.2: this looks to me like a bug, unless I'm missing something.)






      share|improve this answer













      I don't have an exact solution, just one slight improvement for Xcode 4. You could set up a keyboard mapping for "Move Expression Left" (Xcode prefs > Key Bindings), which is a little more than Opt ←:



      s = [NSString string] |


      if | is the cursor position, pressing a "Move Expression Left" keystroke will bring it to the beginning of the expression on the left of it, so in that case before "[NSString". Opt ← will only move before "string".



      (Side note: I do see an action command called "Move to Left end of line" and another one called "Move to beginning of line." To my experience, these do exactly the same behavior in Xcode 4.0.2: this looks to me like a bug, unless I'm missing something.)







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered May 28 '11 at 22:05









      ettoreettore

      533715




      533715








      • 1





        Interesting, could be useful, not sure. I actually find it curious they go to the trouble of implementing these complex expression parsing cursor movements, but manage to keep the simple stuff out.

        – lkraider
        May 30 '11 at 23:18














      • 1





        Interesting, could be useful, not sure. I actually find it curious they go to the trouble of implementing these complex expression parsing cursor movements, but manage to keep the simple stuff out.

        – lkraider
        May 30 '11 at 23:18








      1




      1





      Interesting, could be useful, not sure. I actually find it curious they go to the trouble of implementing these complex expression parsing cursor movements, but manage to keep the simple stuff out.

      – lkraider
      May 30 '11 at 23:18





      Interesting, could be useful, not sure. I actually find it curious they go to the trouble of implementing these complex expression parsing cursor movements, but manage to keep the simple stuff out.

      – lkraider
      May 30 '11 at 23:18











      1














      Tested on XCode 10:



      Step1: Open the file located in the next path by a text editor



       /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist


      Add the next elements to the end of the file:



      <key>Sublime Commands</key>
      <dict>
      <key>Cut Current Line</key>
      <string>selectLine:, cut:</string>
      <key>Copy Current Line</key>
      <string>selectLine:, copy:</string>
      <key>Duplicate Current Line</key>
      <string>selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine:</string>
      <key>Delete Current Line</key>
      <string>selectLine:, deleteToEndOfLine:, moveToEndOfLine:</string>
      <key>Move To First Char In Line</key>
      <string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
      </dict>


      The previous last key 'Move To First Char In Line' will do your request, but I mentioned also other keys.



      Now save the file.



      Step2: Close XCode and reopen it.



      Step3: Navigate to keybinding in xcode preferences then assign your shortcut.



      XCode -> Preferences -> Key Bindings
      Then search for 'Move To First Char In Line' and assign your shortcut.



      enter image description here






      share|improve this answer


























      • Awesome! Tested working on Xcode 8 as well

        – lkraider
        Jan 4 at 21:11
















      1














      Tested on XCode 10:



      Step1: Open the file located in the next path by a text editor



       /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist


      Add the next elements to the end of the file:



      <key>Sublime Commands</key>
      <dict>
      <key>Cut Current Line</key>
      <string>selectLine:, cut:</string>
      <key>Copy Current Line</key>
      <string>selectLine:, copy:</string>
      <key>Duplicate Current Line</key>
      <string>selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine:</string>
      <key>Delete Current Line</key>
      <string>selectLine:, deleteToEndOfLine:, moveToEndOfLine:</string>
      <key>Move To First Char In Line</key>
      <string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
      </dict>


      The previous last key 'Move To First Char In Line' will do your request, but I mentioned also other keys.



      Now save the file.



      Step2: Close XCode and reopen it.



      Step3: Navigate to keybinding in xcode preferences then assign your shortcut.



      XCode -> Preferences -> Key Bindings
      Then search for 'Move To First Char In Line' and assign your shortcut.



      enter image description here






      share|improve this answer


























      • Awesome! Tested working on Xcode 8 as well

        – lkraider
        Jan 4 at 21:11














      1












      1








      1







      Tested on XCode 10:



      Step1: Open the file located in the next path by a text editor



       /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist


      Add the next elements to the end of the file:



      <key>Sublime Commands</key>
      <dict>
      <key>Cut Current Line</key>
      <string>selectLine:, cut:</string>
      <key>Copy Current Line</key>
      <string>selectLine:, copy:</string>
      <key>Duplicate Current Line</key>
      <string>selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine:</string>
      <key>Delete Current Line</key>
      <string>selectLine:, deleteToEndOfLine:, moveToEndOfLine:</string>
      <key>Move To First Char In Line</key>
      <string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
      </dict>


      The previous last key 'Move To First Char In Line' will do your request, but I mentioned also other keys.



      Now save the file.



      Step2: Close XCode and reopen it.



      Step3: Navigate to keybinding in xcode preferences then assign your shortcut.



      XCode -> Preferences -> Key Bindings
      Then search for 'Move To First Char In Line' and assign your shortcut.



      enter image description here






      share|improve this answer















      Tested on XCode 10:



      Step1: Open the file located in the next path by a text editor



       /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist


      Add the next elements to the end of the file:



      <key>Sublime Commands</key>
      <dict>
      <key>Cut Current Line</key>
      <string>selectLine:, cut:</string>
      <key>Copy Current Line</key>
      <string>selectLine:, copy:</string>
      <key>Duplicate Current Line</key>
      <string>selectLine:, copy:, moveToBeginningOfLine:, paste:, moveToEndOfLine:</string>
      <key>Delete Current Line</key>
      <string>selectLine:, deleteToEndOfLine:, moveToEndOfLine:</string>
      <key>Move To First Char In Line</key>
      <string>moveToBeginningOfLine:, moveSubWordForward:, moveSubWordBackward:</string>
      </dict>


      The previous last key 'Move To First Char In Line' will do your request, but I mentioned also other keys.



      Now save the file.



      Step2: Close XCode and reopen it.



      Step3: Navigate to keybinding in xcode preferences then assign your shortcut.



      XCode -> Preferences -> Key Bindings
      Then search for 'Move To First Char In Line' and assign your shortcut.



      enter image description here







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jan 2 at 13:46

























      answered Jan 2 at 13:35









      Mahmoud ShahoudMahmoud Shahoud

      6811716




      6811716













      • Awesome! Tested working on Xcode 8 as well

        – lkraider
        Jan 4 at 21:11



















      • Awesome! Tested working on Xcode 8 as well

        – lkraider
        Jan 4 at 21:11

















      Awesome! Tested working on Xcode 8 as well

      – lkraider
      Jan 4 at 21:11





      Awesome! Tested working on Xcode 8 as well

      – lkraider
      Jan 4 at 21:11











      0














      It seems that the simplest way, as already mentioned is



      1) Go to the beginning of the line (Cmd + left arrow key)



      2) Jump to right word (Alt + right arrow key)



      3) Jump to left word (Alt + left arrow key)



      Unfortunately (Alt + left arrow key) and (Alt + right arrow key) ignores comments, brackets, etc and therefore the method above will not always work. If this is not a problem, then there is also one solution for the BetterTouchTool users. One can create a sequence of actions (commands) that will be called one after another and assign it to Home button. To do so, open the preferences, go to Keyboard tab, Add new shortcut and assign Home button to the (Cmd + left arrow key). Then click Assign additional actions twice, first one for the (Alt + right arrow key) and the second one for the (Alt + left arrow) key commands.



      Hopefully this helps.






      share|improve this answer






























        0














        It seems that the simplest way, as already mentioned is



        1) Go to the beginning of the line (Cmd + left arrow key)



        2) Jump to right word (Alt + right arrow key)



        3) Jump to left word (Alt + left arrow key)



        Unfortunately (Alt + left arrow key) and (Alt + right arrow key) ignores comments, brackets, etc and therefore the method above will not always work. If this is not a problem, then there is also one solution for the BetterTouchTool users. One can create a sequence of actions (commands) that will be called one after another and assign it to Home button. To do so, open the preferences, go to Keyboard tab, Add new shortcut and assign Home button to the (Cmd + left arrow key). Then click Assign additional actions twice, first one for the (Alt + right arrow key) and the second one for the (Alt + left arrow) key commands.



        Hopefully this helps.






        share|improve this answer




























          0












          0








          0







          It seems that the simplest way, as already mentioned is



          1) Go to the beginning of the line (Cmd + left arrow key)



          2) Jump to right word (Alt + right arrow key)



          3) Jump to left word (Alt + left arrow key)



          Unfortunately (Alt + left arrow key) and (Alt + right arrow key) ignores comments, brackets, etc and therefore the method above will not always work. If this is not a problem, then there is also one solution for the BetterTouchTool users. One can create a sequence of actions (commands) that will be called one after another and assign it to Home button. To do so, open the preferences, go to Keyboard tab, Add new shortcut and assign Home button to the (Cmd + left arrow key). Then click Assign additional actions twice, first one for the (Alt + right arrow key) and the second one for the (Alt + left arrow) key commands.



          Hopefully this helps.






          share|improve this answer















          It seems that the simplest way, as already mentioned is



          1) Go to the beginning of the line (Cmd + left arrow key)



          2) Jump to right word (Alt + right arrow key)



          3) Jump to left word (Alt + left arrow key)



          Unfortunately (Alt + left arrow key) and (Alt + right arrow key) ignores comments, brackets, etc and therefore the method above will not always work. If this is not a problem, then there is also one solution for the BetterTouchTool users. One can create a sequence of actions (commands) that will be called one after another and assign it to Home button. To do so, open the preferences, go to Keyboard tab, Add new shortcut and assign Home button to the (Cmd + left arrow key). Then click Assign additional actions twice, first one for the (Alt + right arrow key) and the second one for the (Alt + left arrow) key commands.



          Hopefully this helps.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 8 '16 at 11:05

























          answered Mar 7 '16 at 11:41









          davittariusdavittarius

          12




          12























              0














              In this Xcode extension, Linex, the feature Line Beginning can move to the first non-whitespace character in a line, and also toggle between that and the real beginning.



              Works for Xcode 9, perhaps Xcode 8.






              share|improve this answer




























                0














                In this Xcode extension, Linex, the feature Line Beginning can move to the first non-whitespace character in a line, and also toggle between that and the real beginning.



                Works for Xcode 9, perhaps Xcode 8.






                share|improve this answer


























                  0












                  0








                  0







                  In this Xcode extension, Linex, the feature Line Beginning can move to the first non-whitespace character in a line, and also toggle between that and the real beginning.



                  Works for Xcode 9, perhaps Xcode 8.






                  share|improve this answer













                  In this Xcode extension, Linex, the feature Line Beginning can move to the first non-whitespace character in a line, and also toggle between that and the real beginning.



                  Works for Xcode 9, perhaps Xcode 8.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Oct 13 '17 at 11:45









                  guocguoc

                  37535




                  37535






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f5241092%2fmove-to-beginning-of-text-in-xcode%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Monofisismo

                      Angular Downloading a file using contenturl with Basic Authentication

                      Olmecas