You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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 :scriptnames to 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 .vimrc to exclude $ from auto-pairing (keep only the pairs you actually need):
    let g:AutoPairsMapChars = {'(':')', '[':']', '{':'}',"'":"'",'"':'"'}
    
    If you don’t use the plugin at all, just remove the line that loads it from your .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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 02:33:25