Reputation: 7928
I knew that in the insert mode i can insert the filiename with the path using CTRL-R-%.
But i'd like to insert only the filename without the path part. Is there a similar command for that?
Upvotes: 9
Views: 3652
Reputation: 196466
You can use
<C-r>=expand("%:t")<CR>
See :help filename-modifiers
.
Edit
<C-r>
is used in insert mode to insert the content of a register. "%
is the register that contains the name of the current file.
"=
is the expression register, it contains the result of the expression that comes after =
:
<C-r>=2+27+6<CR> --> 35
<C-r>=expand("%:t")<CR> --> file.txt
Upvotes: 12
Reputation: 58431
While in insert mode, you can use
CTRL-R =expand('%:t')
Upvotes: 2