Yank file name / path of current buffer in Vim

后端 未结 8 1393
死守一世寂寞
死守一世寂寞 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:03

    If you do :reg you will see the name of the current file in the % register. You can paste it with "%p, for example.

    If, like me, you often switch to the 'alternate' buffer, it is very handy that its full path-and-file-name are put in the # register. You can paste it with "#p, for example.

    Note (just in case this is behaviour specific to my setup): I am using VIM 7.4.52 on Ubuntu 14.04.4 LTS.

提交回复
热议问题