Is there a way to only copy/yank the file name to clipboard? According to these sources:
Yank file name / path of current buffer in Vim
How can I expand the full path of the current file to pass to a command in Vim?
Get name of the current file in Vim
it is clear that expand()
is the function to use and the following could be defined:
" Full path
nnoremap <leader><leader>f :let @* = expand("%:p")<CR>
" File name, with extension.
nnoremap <leader><leader>n :let @* = expand("%:t")<CR>
" Extension.
nnoremap <leader><leader>e :let @* = expand("%:t:e")<CR>
" Parent directory, full.
nnoremap <leader><leader>p :let @* = expand("%:p:h")<CR>
However, I did not find a way to copy the file name only. I mean file name
without extension. Is this possible at all? I tried "%"
and "%:
. Neither worked.