Is it possible to copy the absolute filepath of the file under the cursor in Netrw?
You can select the file under cursor through visual block mode, like Ctrl+V
, then press $
and then a j
and then a y
.
Now, in command line mode, Type
:echo @%.@"
This will show the full path of the file under cursor.
You can also map it to a key, Like
:map \f ^<C-V>$jy:echo @%.@"<CR>
Now, you can press \f
while the cursor is on a file and it will print it's full path in command line.
This does not seem to be possible out of the box. Here is a small patch, that should do what you want:
diff --git a/runtime/autoload/netrw.vim b/runtime/autoload/netrw.vim
index de85844..c18d85d 100644
--- a/runtime/autoload/netrw.vim
+++ b/runtime/autoload/netrw.vim
@@ -6052,6 +6052,7 @@ fun! s:NetrwMaps(islocal)
nnoremap <buffer> <silent> <nowait> v :call <SID>NetrwSplit(5)<cr>
nnoremap <buffer> <silent> <nowait> x :<c-u>call netrw#BrowseX(<SID>NetrwBrowseChgDir(1,<SID>NetrwGetWord(),0),0)"<cr>
nnoremap <buffer> <silent> <nowait> X :<c-u>call <SID>NetrwLocalExecute(expand("<cword>"))"<cr>
+ nnoremap <buffer> <silent> <nowait> _ :call setreg(v:register, get(b:, 'current_dir', getcwd()). '/'. <SID>NetrwGetWord())<cr>
" " local insert-mode maps
" inoremap <buffer> <silent> <nowait> a <c-o>:call <SID>NetrwHide(1)<cr>
" inoremap <buffer> <silent> <nowait> c <c-o>:exe "NetrwKeepj lcd ".fnameescape(b:netrw_curdir)<cr>
Using this, you can copy a file path using the _ key