Xcode how to delete current line

Discussion in 'iOS Programming' started by 1458279, Dec 9, 2011.

  1. 1458279 Suspended


    May 1, 2010
    I searched on this and the answers seemed to involve creating keyboard macros.

    What I want to do is delete the current line. Is this already built into Xcode 4?

    I know you can go to the start of the line, highlight the line and delete it, but I was wondering if this is already built in and can be assigned to a key.
  2. xStep macrumors 68000

    Jan 28, 2003
    Less lost in L.A.
    I just use the Emacs short cuts; Ctrl-a Ctrl-k. Ctrl-k a second time will remove the end-of-line on the current line.

    I'm not aware of a shorter method.
  3. 1458279 thread starter Suspended


    May 1, 2010
    Wow, guess I'm going to learn the keyboard macro stuff then :rolleyes:
  4. RonC macrumors regular

    Oct 18, 2007
    KarlJay et al:

    Let me break out the EMACS decoder ring for a second:

    Ctrl-a - Move to the beginning of the line
    Ctrl-k - "Kill" (delete) characters from the current place through to the end of the line UNLESS the only thing on the line is a newline character, in which case it deletes the newline.

    So the sequence ^-a ^-k ^-k moves to the beginning of the line, kills the content then deletes the newline.

    Now lets see if we can avoid the Vi vs EMACS vs SAI (small animal interface) religious wars.
  5. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    triple-click selects a line

    command-left arrow move the insertion point to the start of a line, shift down arrow selects the line.
  6. AlanShutko macrumors 6502a

    Jun 2, 2008
    I have to admit, C-a C-k C-k has worked for me for ... 17 years, so I haven't felt the need to find an alternative.
  7. seepel macrumors 6502


    Dec 22, 2009
    Long time VI user here, how close do Apple text fields/XCode stay true to Emacs shortcuts? Sometimes I go a bit bonkers when I switch from my day job (Programming using vi) to XCode. Religious wars aside, is there enough overlap to justify making the switch?
  8. idelovski macrumors regular

    Sep 11, 2008
    Exactly how I've been doing it since THINK C / Code Warrior days... Feels so natural. One of the few things Xcode 4 hasn't broken. ;)

Share This Page