Tab completion when opening files in Vim
Press :edit %<Tab>
to expand the file path relative to current window.
To expand the path, without the filename, use :edit %:h<Tab>
instead.
For full, absolute path expansion use: :edit %:p<Tab>
.
Sometimes it can be useful to copy the absolute path of the file to open / operate on it somewhere else. I use most when I’m opening another Vim window in a separate display. As the path is copied into system buffer, opening the file is as simple as typing :e ⌘
<kbd>v</kbd>.
noremap <silent> <F4> :let @+=expand("%:p")<CR>
Written by Wojtek Ryrych
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Related Tags
#vim
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#