我正在使用Mac和MacVim 7.3.
我有一个象征性的链接〜/ some / symlink这是一个链接到一个真实的文件〜/ some / actual_file.
当我“vim〜/ some / symlink”时,它使用vim的状态行显示vim中的文件,该名称是〜/ some / symlink,这是有道理的.
如何从vim内部获取“真实”文件〜/ some / actual_file的完整路径?我想要vim状态行说〜/ some / actual_file而不是〜/ some / symlink.
我预计vim函数resolve()将工作,给定它的帮助描述(粘贴在下面),但是解析(“〜/ some / symlink”)返回〜/ some / symlink,所以这没有帮助.
我失踪了什么谢谢!
resolve({filename}) *resolve()* *E655* On MS-Windows,when {filename} is a shortcut (a .lnk file),returns the path the shortcut points to in a simplified form. On Unix,repeat resolving symbolic links in all path components of {filename} and return the simplified result. To cope with link cycles,resolving of symbolic links is stopped after 100 iterations. On other systems,return the simplified {filename}.
您的问题是“〜”,它不是文件名的真正部分,而是您的主目录的缩写.您可以使用expand()然后resolve().例如:
:echo resolve(expand("~/some/symlink"))
expand()也会扩展环境变量(例如:$HOME,$VIMRUNTIME).
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。