I feel like what I am trying to do couldn't be easier. I have this file after/syntax/custom.vim
. It outlines some very simple syntax highlighting rules I want applied to all file types. The highlighting rules work. Hardcoding f_type
to python or something and forcing the filetype will work great! I am attempting to do the following in my .vimrc:
let f_type = &syntax
execute printf("autocmd BufNewFile,BufRead * set syntax=%s.custom", f_type)
I also tried doing &filetype
but this and &syntax
always return an empty string. Any help at all would be lovely.
I followed this Vimscript: how to get current filetype as a variable
some reason this is not working...
Update: I figured out a solution that works but it is... silly.
command APPLYCUSTOM execute printf("set syntax=%s.custom", &syntax)
autocmd VimEnter * APPLYCUSTOM
This seems to work but if I consolidate this to one line it will throw an error (but still work) same thing when trying on the Syntax
event.