Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a nice keyboard shortcut to copy just a quoted string, without the whitespace?

ya' comes awfully close, but as the manual states,

Any trailing white space is included, unless there is none, then leading white space is included.

I don't want the whitespace period. Just quote mark to quote mark, and the stuff inside.

Out of curiosity, what's the use case for keeping the whitespace? (Most vim keys seem to have a reason for doing the things they do…)

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Yes. The keystrokes are

2yi'

See

:help i'

I don't know the reason for sure for keeping the whitespace, but my guess is that it is kept with words in commands such as daw so that you can delete a word without having to delete the preceding or following space separately, and so that you can subsequently paste that word into a sentence without having to add whitespace on either side. From that, the behavior of ya' would follow for consistency.

share|improve this answer
    
While my manual states this behavior, pressing that key sequence doesn't work. For me, the following: :enew i testing <Enter> "hello world" <Esc> 1Gyy2G3l 2yi' o <Esc> p gets me the thing previously yanked ("testing"). (The 2yi' wasn't understood!) (VIM 7.3) –  Thanatos Jan 17 '13 at 1:06
    
i' works with a single-quoted string, e.g., 'hello world'. For a double-quoted string such as "hello world", you need i". –  garyjohn Jan 17 '13 at 1:17
    
Oh, derp, you are correct. I think I somehow expected them to all just be the same, and figure out the quote. But I suppose that could be confusing in the "'foo bar'" case. (Or similar.) –  Thanatos Jan 17 '13 at 1:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.