如何在ViM中禁用匹配括号的自动突出显示(光标短暂跳转到匹配的括号,当插入新的括号时)?
当我在我早期的公司遇到这个问题时,我能够通过在我的下面添加以下内容来解决它 .vimrc
let loaded_matchparen = 1
现在在我的新公司,我面临同样的问题.但是现在这个问题并没有在我的上线中出现.vimrc
.
我尝试添加NoMatchParen
到我的.vimrc,我在打开ViM时遇到以下错误:
Error detected while processing <...>/.vimrc: E492: Not an editor command: NoMatchParen
PL.让我知道解决这个恼人问题的方法.
FYR,我的输出$ 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
user3204934.. 11
let g:loaded_matchparen=1
为我工作!
它设置一个标志,告诉下面的代码/vim/vim81/plugin/matchparen.vim
不声明自己。
let g:loaded_matchparen=1
为我工作!
它设置一个标志,告诉下面的代码/vim/vim81/plugin/matchparen.vim
不声明自己。
由于上述答案中没有一个对我有用(OSX Sierra),我将提供我认为应该在vim的任何(通常的?)配置中工作的内容.
作为OP,在OSX中,vim依赖于插件MatchParen
来突出显示匹配的括号.因此,:set noshowmatch
不会奏效.但是,:NoMatchParen
工作.
现在的问题是配置我们,~/.vimrc
以便在打开文件时默认禁用此插件.
由于将~/.vimrc
旧系统导入到任何新帐户是很常见的,并且在新系统突出显示可能会被切换时show match
,以下内容将在两个实例中自动解决问题:
在您~/.vimrc
添加以下行:
" 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
注意:END
最后augroup
一行很重要.没有它vim
,在文件打开之前调用时会收到一个令人讨厌的通知:
$ vi my file.txt plugin_initialize Press ENTER or type command to continue