Vim插入模式输入$卡顿且自动插入括号,求禁用该异常功能
Fixing the $ Input Lag & Auto-Parentheses Issue in Vim
Hey there! That annoying lag and auto-inserted parentheses when typing $ in insert mode is definitely a plugin-related quirk—let's break down how to track it down and fix it.
Step 1: Confirm it's a plugin problem
First, let's rule out Vim's default behavior. Start Vim without loading any plugins or configs by running:
vim -u NONE
Type $ in insert mode—if there's no lag or auto-parentheses, the issue is definitely from one of your .vimrc plugins.
Step 2: Identify the culprit plugin
You have two straightforward ways to narrow this down:
- Comment out plugins one by one: Open your
.vimrc, add a"at the start of a plugin-loading line to comment it out, save, restart Vim, and test the$input. Repeat until the problem disappears. - Check loaded plugins: In Vim, run
:scriptnamesto see all loaded scripts and plugins. This gives you a clear list of suspects to test.
Common suspect plugins
Most likely, this issue is caused by one of these popular plugins:
- AutoPairs: This plugin auto-matches parentheses and quotes, and misconfigurations can make it trigger on
$with a lag. Test disabling it temporarily with:AutoPairsToggle—if the problem stops, this is your culprit. - vim-surround: While it’s designed for wrapping text, custom mappings might accidentally tie
$to unwanted behavior. - Completion plugins (YCM, CoC, nvim-cmp): If your completion tool uses
$as a trigger for suggestions, it might cause lag while it fetches options in the background.
Step 3: Fix or disable the problematic feature
Once you’ve found the plugin, here’s how to resolve the issue:
- For AutoPairs: Add this line to your
.vimrcto exclude$from auto-pairing (keep only the pairs you actually need):
If you don’t use the plugin at all, just remove the line that loads it from yourlet g:AutoPairsMapChars = {'(':')', '[':']', '{':'}',"'":"'",'"':'"'}.vimrc. - For completion plugins: Check the plugin’s settings for trigger key configurations. For example, in YouCompleteMe, you can change the trigger key to something else with:
let g:ycm_trigger_key = '<C-space>' - Temporary workaround: If you need to type
$quickly right now, use<C-v>$(hold Ctrl, press v, then $) to insert the character directly without triggering any plugin logic.
内容的提问来源于stack exchange,提问作者user9618012
相关产品推荐
相关产品推荐

