You can get the full path of the file you're editing with
expand('%:p'). Unfortunately, we need to edit the path slightly, so this isn't enough on its own, but it gets us closer to where we're going. We need to evaluate that vimscript and put it into the command line as text so we could edit it. Thankfully, we have the expression register.
Here's what I would do:
Open up the command line, and start off your command with
:e<space>. Now press ctrl-r = to open up the expression register. You should see an
= where you normally see the colon.
expand('%:p') and press Enter. You should now see
in your command line.
Use the arrow keys (or ctrl+left) to navigate to the beginning of the path, and edit it to the path you want, then press enter.
I decided that this is something really useful, so I'd like to have it in my config as well. While creating a mapping for it, I realized you could do something much simpler if you use an
<expr> mapping. I did this:
nnoremap <expr> <leader>F ":e ".expand('%:p')
(Of course, you can pick whatever you want in place of
<leader>F) This works be evaluating everything after the mapping as a string, and returning those keystrokes as if you typed them.
":e " Obviously corresponds to
:e<space> since that's the beginning of the command you'll use.
. is the string concatenation operator
expand('%:p') evaluates to the full path like before.
This is overall simpler since it doesn't require the