Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional options in .vimrc for Scheme

Tags:

vim

scheme

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
like image 424
zallarak Avatar asked Feb 19 '23 00:02

zallarak


2 Answers

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
like image 102
Michael Berkowski Avatar answered Feb 24 '23 09:02

Michael Berkowski


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. :)

like image 40
greduan Avatar answered Feb 24 '23 09:02

greduan