Return drive letter for find file in vim script?

I use a function findfile()in Vim to get the full path to a file. It seems that the returned path (if found) does not contain the drive letter (and :, for example c:)) on Windows , so there may be a problem using this path. Is there a way to get a driver letter for the return path, or can a dedicated function do this?

+4
source share
1 answer

The path returned findfile()is correct with respect to the current working directory, so as long as you don't change it, using it directly should be great.

If you need to switch buffers or do other things that might affect CWD, you can deploy the spec file to its full absolute form with:

let absoluteFilespec = fnamemodify(findfile(...), ':p')
+1
source

Source: https://habr.com/ru/post/1568527/


All Articles