Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
277 views
in Technique[技术] by (71.8m points)

In Vim, how to copy content in file and use it in command?

For example, I open a file which includes

FATAL ERROR: Simulation failed. Please read /path/to/the/error/file.error

What I want to do is copy the path of the error file, which I've already done that by "v" into the visual mode and "y" to copy it, and open that file by splitting the window by ":sp /path/to/the/error/file.error".

My problem is: how to paste the copied path in command mode?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Vim also has a feature to open the filename under the cursor directly.

If you want to open it in a new split, then you can use Ctrl+W, f (or the equivalent Ctrl+W, Ctrl+F).

See :help CTRL-W_f for more details.

The mapping to open the file under the cursor in the current window (not in a new split) is gf.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...