1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to? Remove last argument on command line

Discussion in 'Support' started by Avi Shmidman, May 8, 2012.

  1. Avi Shmidman

    Joined:
    Feb 23, 2012
    Messages:
    238
    Likes Received:
    3
    I find myself often repeating the following sequence:
    1] I hit up-arrow on the command line to go to a previous command
    2] I erase the last argument of that command (usually a filename)
    3] I fill in a new filename for the argument (usually by typing a mask and using autocomplete) and hit enter.
    The item that I'd like to figure out how to do more efficiently is step #2. How can I remove that last argument with a single keypress?
    Right now, after recalling that previous command, I can backspace over the last argument, or I can use shift-left-arrow to select it and then delete it. The problem is that a single shift-left-arrow generally doesn't do the job, because shift-left-arrow doesn't select a whole argument; rather, it stops at underscores, dashes, and periods, and I often find that I have to press shift-left-arrow 4 or 5 times until I select the whole filename.
    Hence, I'm wondering: is there a way to erase the entire argument with a single keystroke?
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,277
    Likes Received:
    38
    My fingers have learned Control-L to erase the word to the left of the cursor. Yes, it may be necessary to press it several times, but that never bothered me.
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,785
    Likes Received:
    29
    I figured there had to be an erase_word_left, but that one works oddly with quoted strings. For example, if you start with

    a "b c"

    the first Ctrl-L erases c
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,785
    Likes Received:
    29
    Well that got all fouled up by my putting "quote" in brackets! I'll try again. If I start with

    a "b c"

    the first Ctrl-L erases c-quote, the second erases b-space, and the third erases the remaining quote.

    Two would be better (erase c-quote, then quote-b-space). Better yet, only one (erase the entire quoted arg).
     
  5. Avi Shmidman

    Joined:
    Feb 23, 2012
    Messages:
    238
    Likes Received:
    3

Share This Page