Yank file name / path of current buffer in Vim

后端 未结 8 1373
死守一世寂寞
死守一世寂寞 2020-12-07 07:26

Assuming the current buffer is a file open for edit, so :e does not display E32: No file name.

I would like to yank one or all of:

8条回答
  •  既然无缘
    2020-12-07 08:00

    Answer tested on Neovim/Ubunutu.

    From what I can tell, the % register already contains the relative filepath, so it's as simple as moving the contents of the % register to whatever register represents your favourite clipboard.

    This SO answer deals with copying from one register to another

    :let @+=@%
    

    Seems pretty straightforward to me. No need for any hard-to-remember expand() stuff.

提交回复
热议问题