Error detected while processing BufWinEnter Autocommands for "*"..function <SNR>3_LocalVimRC[322]..BufWinEnter Autocommands for "*"..function <SNR>3_LocalVimRC:
line  263:
E654: missing delimiter after search pattern: Vim\%((\a\+)\)\=:E48

I've re-installed vim using brew install vim and I've moved all vim configs and the folder to backups.

Results from running :scriptnames

  1: /usr/share/vim/vimrc
  2: /usr/share/vim/vim82/defaults.vim
  3: ~/.vim/plugin/localvimrc.vim
  4: /usr/share/vim/vim82/plugin/getscriptPlugin.vim
  5: /usr/share/vim/vim82/plugin/gzip.vim
  6: /usr/share/vim/vim82/plugin/logiPat.vim
  7: /usr/share/vim/vim82/plugin/manpager.vim
  8: /usr/share/vim/vim82/plugin/matchparen.vim
  9: /usr/share/vim/vim82/plugin/netrwPlugin.vim
 10: /usr/share/vim/vim82/plugin/rrhelper.vim
 11: /usr/share/vim/vim82/plugin/spellfile.vim
 12: /usr/share/vim/vim82/plugin/tarPlugin.vim
 13: /usr/share/vim/vim82/plugin/tohtml.vim
 14: /usr/share/vim/vim82/plugin/vimballPlugin.vim
 15: /usr/share/vim/vim82/plugin/zipPlugin.vim

I haven't touched any of the above files.

If I move my vimrc file back and run :PlugInstall, i get the following error:

Error detected while processing function <SNR>10_install[1]..<SNR>10_update_impl[53]..<SNR>10_prepare[18]..<SNR>10_new_window[1]..BufWinEnter Autocommands for "*"..function <SNR>19_LocalVimRC[322]..function <SNR>
10_install[1]..<SNR>10_update_impl[53]..<SNR>10_prepare[18]..<SNR>10_new_window[1]..BufWinEnter Autocommands for "*"..function <SNR>19_LocalVimRC:                                                                  
line  263:                                                                                                                                                                                                          
E654: missing delimiter after search pattern: Vim\%((\a\+)\)\=:E48                                                                                                                                                  
Error detected while processing function <SNR>10_install[1]..<SNR>10_update_impl[53]..<SNR>10_prepare:                                                                                                              
line   18:                                                                                                                                                                                                          
E171: Missing :endif        

The most noticable thing I'm missing is nerdtree.

Here's my vimrc file, although i don't think vim is even getting that far:

" Set compatibility to Vim only.
set nocompatible

" Helps force plug-ins to load correctly when it is turned back on below.
filetype off

" Turn on syntax highlighting.
syntax on

" Just... required for colours. Should be default in vim -.-
set t_Co=256
set termguicolors

" Tells vim that you want a dark colour scheme (just a setting, doesn't affect background)
set background=dark

" For plug-ins to load correctly.
filetype plugin indent on

" tab length
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab

" expected backspace behaviour
set backspace=indent,eol,start

" Display 5 lines above/below the cursor when scrolling with a mouse.
set scrolloff=5

" Speed up scrolling in Vim
set ttyfast

" set line number
set number

" Encoding
set encoding=utf-8

" Highlight matching search patterns
set hlsearch

" speed up redrawing with all the macros
set lazyredraw

" ignore these files for things
set wildignore+=*/node_modules/*,*.swp,

" display cursor line in status
set cursorline

" split new windows to bottom and right
set splitright
set splitbelow

" set font
set guifont=Menlo\ Regular:h18

" more buffer history
set history=100

"~~Persistent Undo~~"
let vimDir = '$HOME/.vim'
let &runtimepath.=','.vimDir

" Keep undo history across sessions by storing it in a file
if has('persistent_undo')
    let myUndoDir = expand(vimDir . '/undodir')
    " Create dirs
    call system('mkdir ' . vimDir)
    call system('mkdir ' . myUndoDir)
    let &undodir = myUndoDir
    set undofile

" ~~~ home row movement ~~~ "
" ~~~~~~~~~~~~~~~~~~~~~~~~~ "
noremap ; l
noremap l k
noremap k j
noremap j h

" ~~~ moving windows with z ~~~ "
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "
noremap zj <C-W><Left>
noremap zk <C-W><Down>
noremap zl <C-W><Up>
noremap z; <C-W><Right>

" ~~~ shortcuts! ~~~ "
" ~~~~~~~~~~~~~~~~~~ "
let mapleader=","

call plug#begin('~/.vim/plugged')

" Linting
Plug 'w0rp/ale'

" Language plugins
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'tikhomirov/vim-glsl'
Plug 'leafgarland/typescript-vim'
Plug 'elzr/vim-json'
Plug 'stephpy/vim-yaml'
Plug 'udalov/kotlin-vim'

" command plugins
Plug 'tpope/vim-fugitive'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tpope/vim-commentary' " gc to comment out a line

" UI plugins
Plug 'luochen1990/rainbow'
Plug 'airblade/vim-gitgutter'
Plug 'vim-airline/vim-airline'
Plug 'ap/vim-css-color'
Plug 'nathanaelkane/vim-indent-guides'

" Utility
Plug 'scrooloose/nerdtree'

call plug#end()

" Use JSX syntax highlighting in TSX files
autocmd BufRead,BufNewFile *.tsx setlocal syntax=javascript.jsx

set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

" rainbow brackets
let g:rainbow_active = 1

let g:indent_guides_enable_on_vim_startup = 1

let b:ale_fixers = {'javascript': ['eslint --ext .js,.ts,.jsx,.tsx']}
let g:ale_lint_delay = 500

let NERDTreeShowHidden=1
let g:NERDTreeDirArrowExpandable = '>'
let g:NERDTreeDirArrowCollapsible = 'v'

colorscheme meta5

" Commands to run at the beginning
autocmd VimEnter * if argc() == 0 | NERDTree | endif
autocmd VimEnter * if argc() == 0 | wincmd p | endif

Everything worked before the upgrade.

  • 1
    Given that this is after an OS upgrade, I wonder if it is due to a version mismatch or compiled features. Can you confirm that you are running homebrew’s vim when you execute vim and get this error (check with which vim)? The next step would be to remove all of your config files and incrementally add them back in. Commented Jun 1, 2021 at 19:11
  • 1
    Complaint about <SNR>3_LocalVimRC suggests the problem is on that ~/.vim/plugin/localvimrc.vim file of yours... What do you have in there? Particularly, on line 263 of that file? It's odd that it seems that file is being loaded before your vimrc... Usually, vimrc should be loaded first. Is there something unusual about the location of your vimrc file?
    – filbranden
    Commented Jun 1, 2021 at 19:23
  • 2
    There's a lot here that is not making a lot of sense... If you have vim-plug, you should have plug.vim installed somewhere and showing up in your scriptnames. If you took your vimrc out of the way, then what is configuring which plug-ins to install? You say the localvimrc.vim file is being auto-generated, but there really isn't something that auto-generates such a file...
    – filbranden
    Commented Jun 1, 2021 at 21:33
  • 2
    What localvimrc file is that? and where does it come from? BTW: I think @filbranden meant line 263 of the function LocalVimRC and not of the file. I had a quick look at github.com/vim-scripts/localvimrc but that seems to be a different one Commented Jun 2, 2021 at 6:49
  • 1
    I'm still puzzled by your mention that "I've moved all vim configs and the folder to backups", because if you took the whole ~/.vim out of the way, that localvimrc.vim file wouldn't be there, there's nothing that creates Vim files there AFAICT... In any case, I seem to have found the syntax error in that script, so I posted an answer about it.
    – filbranden
    Commented Jun 2, 2021 at 12:46

2 Answers 2


Looks like your ~/.vim/plugin/localvimrc.vim is an older version (pre v3.1.0) of the embear/vim-localvimrc plug-in.

A recent commit (well, from over a year ago, but released as v3.1.0) fixed an issue such as the one you described.

See commit 7974cd4872. Before that commit, line 491 used to have:

    catch ^Vim\%((\a\+)\)\=:E48

After that commit, code was shifted around, but this same catch with a regexp is now on line 214, updated to:

    catch /^Vim\%((\a\+)\)\=:E48:/

User df7cb on GitHub commented on that line:

This change fixes a warning with recent vim versions (8.2) on each file open. Could you release a new version?

This pretty much matches what you're seeing here... So upgrading this script to the latest version would fix it.

Actually, if you do indeed need and want this plug-in installed, my recommendation is that you remove it from your .vim/, where I assume it was installed manually, and use vim-plug to manage it directly from the GitHub, which can be done with:

Plug 'embear/vim-localvimrc'

This will have vim-plug download and install it under the ~/.vim/plugged tree. It will install the latest version from GitHub, which should include all relevant fixes.

  • 1
    This was a very well written answer, but I have not tested it. When you mentioned my situation appeared impossible, I realized you were correct and took a different route. Thanks for all the help. You led me to a different answer that worked, which was basically "turn it off and back on again" :p Commented Jun 8, 2021 at 21:06

Filbranden helped me realize that the context of my question did not make sense. The file couldn't have been auto-generated. I purged that folder properly and reinstalled everything, and now vim works.

So if anyone is having weird issues with vim, purging everything and re-installing it, may solve your problem, as it solved mine. If you get the exact same error I got, see filbranden's answer above, because it might explicitly fix your problem. However, that answer wasn't how I solved my problem.

Your Answer

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

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