I want to toggle color-matching parens in vim when I am editing a scheme/lisp file. How can I conditionally run something in my .vimrc?
Something like:
if syntax == scheme:
RainbowParenthesesToggle
EDIT: Currently I activate it manually
:RainbowParenthesesToggle
Use an autocmd
based on the scheme
filetype:
autocmd FileType scheme RainbowParenthesesToggle
Or based on the plugin documentation, RainbowParenthesesLoadRound
to initialize it for ()
specifically:
autocmd FileType scheme RainbowParenthesesLoadRound
If you want to use auto commands you can follow @MichaelBerkowski's advice. However if you prefer you can also do the following:
if (&ft == 'scheme')
:RainbowParenthesesToggle " Toggle it on/off
:RainbowParenthesesLoadRound " (), the default when toggling
:RainbowParenthesesLoadSquare " []
:RainbowParenthesesLoadBraces " {}
:RainbowParenthesesLoadChevrons " <>
endif
&ft
stands for filetype, so you can access this variable to know the current buffer's filetype. Check :h ft
for more info.
Of course you can also have various auto commands inside this if statement, if you want to refine it a little more, or more if statements, whatever you want.
Remember the parenthesis are optional, I just like to use them. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With