How to open a directory under the cursor in vim? Gf-like for directories

For example, if I had something like:

path = '/mnt/data/files/'

and my cursor was over '/mnt/data/files/', I hit the gf-like command and it will open vim :Explorerin this folder.

I searched through StackOverflow, but I only found answers on how to open the directory of the current open file.

+4
source share
1 answer

Pressing <C-r><C-f>on the command line inserts the path under the cursor. This means that you can do the following to achieve your goal:

:Ex <C-r><C-f><CR>

From there, you can simply create a custom mapping:

nnoremap <key> :Explore <C-r><C-f><CR>
+5
source

All Articles