Thursday, August 7, 2014

Re: Doing "gf" from a gvim file opens the target file but switches off the syntax setting

On 05:49 Thu 07 Aug , Melvin Simon wrote:
> Hi,
>
> When I do "gf" from a gvim file to g odiretly to another file, I lose my current syntax setting. Doesn't ~/.gvimrc apply in when I do "gf".
>
> Also, how do I fix this issue?
>
> Thanks for your support,
> gvim newbie.

Hi,

~/.gvimrc (and ~/.vimrc) are only sourced on startup (':help vimrc' inside
':help startup' help section; and ':help gvimrc'). So yes none of them
will be source when you use the gf normal command. From the other side,
syntax settings are specific to a buffer. If you want to source some
commands (set some settings) for all the files which shares this
particular syntax type or file type you can place a vim script under

~/.vim/after/syntax/
or
~/.vim/after/filetype/

Read about the after directory: ':help after-directory'. The script has
to be named correctly though. You can inspect $VIMRUNTIME directory
(syntax and filetype subfolders of it).

Best regards,
Marcin Szamotulski

No comments: