1

I would like to know if there is some way to make vim always highlight according to the targets extension rather than the symlink's extension

I wrote a small shell function that can do what I want but it is not perfect.

Here is my function:

function myVI () {
   local filename=$(readlink $1);
   vim -c "cd $(dirname $1)" "$filename";
}

This is not ideal I prefer a native vim cmd if it exist.

I J
  • 65
  • 5

1 Answers1

0

It is pretty hard to determine filetype by file name or extension in vimscript if there are no modelines that can help you in this file. But you can add this to your vimrc

"" opens original file instead of symlink
autocmd BufEnter * if getftype(expand("%")) == 'link' | execute 'file '.system('readlink '.expand('%')) | endif
Sardorbek Imomaliev
  • 12,796
  • 2
  • 39
  • 50