juniper-
juniper-

Reputation: 6572

Vim yank path under the cursor

What's the most efficient way to yank a path that's under a cursor? So if a line has the following contents:

/some/file /some/other/file /last/file

... and the cursor is over other, I would like to yank /some/other/file. Normally, if it were a word yiw would work, but since that path contains quotes, yiw would only yank other rather than the entire /some/other/file.

Is there a way to efficiently yank the entire filename?

Upvotes: 3

Views: 412

Answers (3)

Ian H
Ian H

Reputation: 542

Byt<space>: B to go to the start of the file location, yt<space> to yank up to the next line space.

Upvotes: 0

Peter Lewerin
Peter Lewerin

Reputation: 13282

While I would use yiW as in dave's answer, ByE (go to beginning of WORD, yank to end of WORD) is another possibility.

Upvotes: 0

dave
dave

Reputation: 64707

A word consists of a sequence of letters, digits and underscores, or a sequence of other non-blank characters, separated with white space (spaces, tabs, ). This can be changed with the 'iskeyword' option. An empty line is also considered to be a word.

A WORD consists of a sequence of non-blank characters, separated with white space. An empty line is also considered to be a WORD.

yiW - just need to capitalize the W

Upvotes: 9

Related Questions