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 up the file in vim with vim's status line saying the name is ~/some/symlink, which makes sense.
How do I get the full path of the "real" file ~/some/actual_file from within vim? I want the vim status line to say ~/some/actual_file instead of ~/some/symlink.
I expected that the vim function resolve() would work, given its help description (pasted below), but resolve("~/some/symlink") returns ~/some/symlink, so that's no help.
What am I missing? Thanks!
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}.
If all that is wanted is to display the name of the current file, type Ctrl-G (or press 1 then Ctrl-G for the full path).
Yes. They both take space as they both still have directory entries. A hardlink entry (really, a "normal entry" that [often] shares an inode) takes space, as does a symlink entry which must store the link path (the text itself) somehow.
You use the ln command to create the links for the files and the -s option to specify that this will be a symbolic link. If you omit the -s option, then a hard link will be created instead. The existing_source_file represents the file on your computer that you want to create the symbolic link for.
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
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With