How to expand a symbolic link to the full path of a filename in vim?

前端 未结 1 1807
谎友^
谎友^ 2021-02-13 14:27

I\'m using a Mac and MacVim 7.3.

I have a symbolic link ~/some/symlink which is a link to a real file ~/some/actual_file.

When I \"vim ~/some/symlink\" it brings

相关标签:
1条回答
  • 2021-02-13 15:10

    Your problem is the "~", which isn't really part of the filename, but instead a shorthand for your home directory. You can use expand() and then resolve(). eg:

    :echo resolve(expand("~/some/symlink"))
    

    expand() will also expand things like environment variables (eg: $HOME, $VIMRUNTIME).

    0 讨论(0)
提交回复
热议问题