26

How to disable auto highlighting of Matched Parentheses (cursor briefly jumping to the matched bracket, when a new bracket is inserted) in ViM?

When I faced this issue in my earlier company, then I was able to resolve it by adding below line to my .vimrc

let loaded_matchparen = 1

Now in my new company I am facing the same problem. But now the issue doesn't go even with above line in my .vimrc.

I tried adding, NoMatchParen to my .vimrc, I am getting following error when opening ViM:

Error detected while processing <...>/.vimrc:
E492: Not an editor command: NoMatchParen

Pl. let me know a work around for this annoying issue.

FYR, Output of my $ vim --version:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 11 2012 21:05:37)
Compiled by rvictor@depbldrh61
Huge version with GTK2 GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff 
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi 
+file_in_path +find_in_path +float +folding -footer +fork() +gettext 
-hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall 
+linebreak +lispindent +listcmds +localmap -lua +menu +mksession +modify_fname 
+mouse +mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm 
-mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg 
-osfiletype +path_extra -perl +persistent_undo +postscript +printer +profile 
-python -python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs 
+smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary 
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo 
+vreplace +wildignore +wildmenu +windows +writebackup +X11 -xfontset +xim 
+xsmp_interact +xterm_clipboard -xterm_save 
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/depot/vim-7.3/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12     -g -O2 -D_FORTIFY_SOURCE=1      
Linking: gcc   -L/usr/local/lib -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -lXt -lm -lncurses -lselinux -lacl 
BluVio
  • 449
  • 1
  • 5
  • 11

4 Answers4

31

As none of the above answers worked for me (OSX Sierra), I will provide what I think should work in any (of the usual?) configuration of vim.

As the OP, in OSX vim relies on the plugin MatchParen for highlighting the matching parentheses. Thus, :set noshowmatch will not work. However, :NoMatchParen works.

The question is now to configure our ~/.vimrc so that this plugin is disabled by default when opening a file.

As it's common to import our ~/.vimrc from old system to any new accounts, and in the new system highlighting might be toggled by show match, the following will address the issue automatically in both instances:

In your ~/.vimrc add the following lines:

" Disable parentheses matching depends on system. This way we should address all cases (?)
set noshowmatch
" NoMatchParen " This doesnt work as it belongs to a plugin, which is only loaded _after_ all files are.
" Trying disable MatchParen after loading all plugins
"
function! g:FckThatMatchParen ()
    if exists(":NoMatchParen")
        :NoMatchParen
    endif
endfunction

augroup plugin_initialize
    autocmd!
    autocmd VimEnter * call FckThatMatchParen()
augroup END

Note: the END in the last augroup line is important. Without it you get a pesky notification when calling vim before your file gets open:

$ vi my file.txt  
plugin_initialize  
Press ENTER or type command to continue
MASL
  • 929
  • 1
  • 11
  • 25
30
let g:loaded_matchparen=1

worked for me!

It sets a flag that tells code under /vim/vim81/plugin/matchparen.vim to not assert itself.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
user3204934
  • 485
  • 6
  • 15
7

Check your vimrc for showmatch or sm.

:set noshowmatch or :set nosm disables the brief jumping.

Alan W. Smith
  • 24,647
  • 4
  • 70
  • 96
cshu
  • 5,654
  • 28
  • 44
3

If you have disabled the MatchParen plugin, then there will be no command NoMatchParen available (since loading the plugin is skipped). What exactly do you want to achieve? Perhaps you are looking for the :set noshowmatch command (which you can put into your .vimrc)?

Christian Brabandt
  • 8,038
  • 1
  • 28
  • 32
  • For future readers: using the command `NoMatchParen` for checking is still useful now. And If you're Neovim macOS user, you still need to set `vim.g.loaded_matchparen = 1` to disable the plugin. – NeoZoom.lua Jan 31 '23 at 13:48