If you need to do this frequently, it might be useful to bind a key sequence to what you want, as per http://vim.wikia.com/wiki/Insert_current_filename
inserts the current filename without the extension at the cursor position, when you are in insert mode.
:inoremap \fn <C-R>=expand("%:t:r")<CR>
To keep the extension use:
:inoremap \fn <C-R>=expand("%:t")<CR>
To insert the absolute path of the directory the file is in use:
:inoremap \fn <C-R>=expand("%:p:h")<CR>
To insert the relative path of the directory the file is in use:
:inoremap \fn <C-R>=expand("%:h")<CR>
The above all work directly in vim
for the session, or you can put it in the .vimrc
(where the leading colon on the line is optional).
<c-r>
mapped as the redo command? – J.C. Yamokoski Dec 04 '12 at 15:38<c-r>
specifies that the next character is a register. – Kevin Dec 04 '12 at 15:43"%p
in normal or visual modes. – naught101 Aug 25 '17 at 02:36