gpt4 book ai didi

vim - 有符号链接(symbolic link)时获取 VIM 中的逻辑路径

转载 作者:行者123 更新时间:2023-12-04 19:37:04 26 4
gpt4 key购买 nike

我有以下设置:

mkdir /1
mkdir /1/2
mkdir /1/2/3
ln -s /1/2/3 /1/3

如果我执行 cd/1/3,然后执行 pwd,我会得到 /1/3。如果我使用pwd -P,我可以获得/1/2/3,或者pwd -L来强制/1/3

在 VIM 中,我正在寻找一种获取 /1/3 的方法。
如果我在 /1/3/foo.txt 中打开一个文件,并且我使用类似 fnamemodify(bufname(winbufnr(0)), ':p:h'),它返回 /1/2/3
我如何告诉它给我 pwd 会给我的同一目录?

最佳答案

看来你不能,除非通过 system('pwd -L')。根据vim_use mailing list如今,Vim 会自动解析符号链接(symbolic link)。

请参阅围绕 :h E773 的文本以了解基本原理;如果 Vim 使用符号链接(symbolic link)而不是解析的文件名,则可能会以两个不同的名称在两个缓冲区中打开同一个文件,并且 Vim 会在试图找出交换文件的位置时感到困惑。另见 :h version7.txt:

Unix: When editing a file through a symlink the swap file would use the name of the symlink. Now use the name of the actual file, so that editing the same file twice is detected.

关于vim - 有符号链接(symbolic link)时获取 VIM 中的逻辑路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26606719/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com