Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim edit a symlink

Tags:

vim

symlink

I want to edit a file with (:e) which is a symlink and make vim follow it. I dont want this to be the default behavior or anything.

I know that using resolve and expand I can get full link.

:echo resolve(expand("~/.vimrc"))

prints the full link.

I want to be able to do something like this

:e resolve(expand("~/.vimrc"))

Note: I want it to follow the symlink because of context, like quickly editing other files in that folder and stuff like that.

like image 711
Ahmed Aeon Axan Avatar asked Aug 08 '13 12:08

Ahmed Aeon Axan


1 Answers

You can insert any Vimscript expression into the command-line via <C-r> and the expression register =:

:e <C-r>=resolve(expand("~/.vimrc"))<CR><CR>

Alternatively, for files, there's the rather obscure backtick expansion of Vimscript:

:e `=resolve(expand("~/.vimrc"))`<CR>
like image 122
Ingo Karkat Avatar answered Oct 06 '22 00:10

Ingo Karkat