Hacker News new | ask | show | jobs
by wahnfrieden 4810 days ago
Isn't there some way of using % to open a file relative to the current one perhaps? To get the best of both worlds.
2 comments

I'm using the following to expand "%%" in command mode to the full path of the current open file's directory:

  cabbr <expr> %% expand('%:p:h')
You could also use :. instead of :p to get the relative path, see :help c_% and :help filename_modifiers
Wow, elegant. Thank you!
I use:

    map <leader>e :e <C-r>=expand("%:p:h") . "/" <cr>
you can make one that splits:

    map <leader>v :vs <C-r>=expand("%:p:h") . "/" <cr>