I am trying out MacVim for the first time and Vim seems to think I have a surplus of closing parentheses:

enter image description here

However, Vim seems to change it's mind. Each highlighted closing parenthesis is no longer highlighted after placing the cursor over it. I demonstrate this in a short video:


(Notice the highlighted closing parentheses at the end of the 1st, 3rd, and 4th procedure definition.)

I confirmed that the parentheses are balanced using DrRacket, and the code does compile and run properly. In an attempt to troubleshoot, I tested the code using MacVim on a different user account on the same computer. Parentheses were still being highlighted as if they were surplus.

The full text of the file, named yetanotherscm.scm is here:

(define atom?
  (lambda (x)
    (and (not (pair? x)) (not (null? x)))))

(define lat?
  (lambda (l)
      ((null? l) #t)
      ((atom? (car l))(lat? (cdr l)))
      (else #f))))

(define member?
  (lambda (a lat)
      ((null? lat) #f)
      ((eq? a (car lat)) #t)
      (else (member? a (cdr lat))))))

(define rember
  (lambda (a lat)
      ((null? lat) lat)
      ((eq? a (car lat))(cdr lat))
      (else (cons (car lat) (rember a (cdr lat)))))))

(define firsts
  (lambda (l)
      ((null? l) '())
      (else (cons (car (car l)) (firsts (cdr l)))))))

(define sbst 
  (lambda (new old lat)
      ((null? lat) '() )
      ((eq? (car lat) old)(cons new (cdr lat)))
      (else (cons (car lat) (sbst new old (cdr lat)) )))))
(sbst 'joseph 'hpesoj '(joseph spelt backwords is hpesoj is it not?))

(define multirember
  (lambda (a lat)
      ((null? lat) lat)
      ((eq? (car lat) a)(multirember a (cdr lat)))
      ((cons (car lat) (multirember a (cdr lat)))))))

(define multiinsertR
  (lambda (new old lat)
      ((null? lat) lat)
      ((eq? (car lat) old)(cons old (cons new (multiinsertR new old (cdr lat)))))
      (else (cons (car lat) (multiinsertR new old (cdr lat)))))))

(multiinsertR 'new 'old '(this table is old and i am happy that it is old so old happy))

(define multiinsertL2
  (lambda (new old lat)
    ((null? lat) lat)
    ((eq? (car lat) old)(cons new (cons old (multiinsertL2 new old (cdr lat)))))
    (else (cons (car lat) (multiinsertL2 new old (cdr lat))))

(multiinsertL2 'fried 'fish '(chips and fish or fish and fried))

(define multisubst
  (lambda (new old lat)
      ((null? lat) lat)
      ((eq? (car lat) old) (cons new (multisubst new old (cdr lat))))
      (else (cons (car lat) (multisubst new old (cdr lat)))))))

(multisubst 'joe 'joseph '(joseph is a pretty cool guy joseph was not here joseph))

(define two-in-a-row
  (lambda (lat)
      ((null? lat) #f)
      ((eq? (car lat) (car (cdr lat) #t)))
      (else (two-in-a-row (cdr lat))))))

The version of Vim/MacVim:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun  8 2015 16:45:59)
MacOS X (unix) version
Included patches: 1-712
Compiled by Homebrew
  1. Do you have any idea what's going on?
  2. What steps can i take to correct this?
  3. Is there a user preferences file(s)/folder(s) i can delete, so I can reinstall MacVim through Homebrew?

1 Answer 1


I can reproduce the problem on my Linux system running Vim 7.4.729 as gvim. The problem appears to be the synchronizing of Vim's syntax highlighting engine. To save time, Vim doesn't always look at the whole file to figure out how to highlight it. In this case, Vim isn't looking back far enough in the file to see the opening parenthesis, so it thinks any parenthesis that would close it is extra. See

:help :syn-sync

I can fix the problem by executing

:syntax sync fromstart

To fix the problem permanently, at the expense of taking longer to open larger Scheme files, you can put that statement in a file named ~/.vim/after/syntax/scheme.vim. ~/.vim would be the directory on a Unix system for your personal configuration files. I think the location is the same or similar on a Mac. See also

:help mysyntaxfile-add
  • I've been using autocmd BufEnter * :syntax sync fromstart for ages. It's not just Scheme where this will fix problems (IMHO this should be the default). Jun 9, 2015 at 9:08
  • 5
    @Carpetsmoker Things are not as clear-cut as you make them seem. Highlighting for some languages can be really slow, and that might be amplified by the fact that the new regexp engine is still buggy. Sometimes you can workaround the slowness by setting re=1 to force the use of the old engine, but sometimes there just isn't any solution. Running sync fromstart in that situation would be a pretty bad idea.
    – lcd047
    Jun 9, 2015 at 9:33
  • If :syntax sync fromstart causes too much delay, perhaps I should disable the default feature all together. And find a way to toggle :syntax sync fromstart. That way, I can avoid delay and still check for balanced parentheses via a command/shortcut. Do you know how I can set up a command/shortcut combo to toggle ":syntax sync fromstart"? Jun 9, 2015 at 22:03
  • Toggling is a little tricky because the type of syntax syncing used for each filetype is set by the filetype's syntax file and varies with the filetype. I think the following will work, though. map <silent> <F8> :if exists("g:fromstart") <bar> syn off <bar> syn on <bar> unlet g:fromstart <bar> else <bar> syn sync fromstart <bar> let g:fromstart=1 <bar> endif <cr>
    – garyjohn
    Jun 10, 2015 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.