0

Is it possible to Highlight bash internal varibles using VIM?

For example the variables described on this page would appear a different colour than the user defined variables.

http://tldp.org/LDP/abs/html/internalvariables.html

1 Answer 1

2

You can define additional syntax keywords for those built-in variables. Put the following into ~/.vim/after/syntax/sh.vim:

syntax keyword shBuiltInVariable BASH BASH_ENV BASH_VERSION containedin=shDerefSimple
highlight def link shBuiltInVariable Special

The containedin= is necessary because shell variables are already parsed by existing syntax groups, and these additional overrides need to go in there to match.

Also note that $VIMRUNTIME/syntax/sh.vim supports multiple shell dialects; if you use different shells, you need to add proper conditionals (b:is_bash etc.) around your additions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.