Is there a (simple) way to yank the filename of specific buffer in insert mode?

For example, in insert mode, Ctrl+R % gives the name from current buffer, Ctrl+R # gives the alt one, but what about an arbitrary number, for example 1, for buffer 1?

2 Answers 2


One way to accomplish this is to use the expression register = together with the bufname() function.

In Insert mode, you can enter the following sequence: Ctrl+R, =, bufname(1), Enter, which will insert the name of buffer 1 into the current location.

  • 1
    and/or "=bufname(1)<CR>p
    – D. Ben Knoble
    Mar 10, 2022 at 14:18

if you mean paste by yank then you can use :h bufname() function and = expression register: <C-r>=bufname(1)<CR>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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