Yamaneko
Yamaneko

Reputation: 3563

How do I open a directory under the cursor in vim? A gf-like for directories

For instance, if I had something like:

path = '/mnt/data/files/'

and my cursor was over '/mnt/data/files/', I'd hit a gf-like command and it would open vim :Explorer in that folder.

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

Upvotes: 4

Views: 873

Answers (1)

romainl
romainl

Reputation: 196466

Pressing <C-r><C-f> in 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 could simply create a custom mapping:

nnoremap <key> :Explore <C-r><C-f><CR>

Upvotes: 7

Related Questions