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

VS Code保存后多行内容合并为一行问题求助

Fix: VS Code Merges Multi-Line Text into One Line on Save

Hey there! Let's troubleshoot why your multi-line text is getting squashed into a single line with automatic numbering when you hit Ctrl+S in VS Code. This issue almost always stems from misconfigured auto-formatting settings or an overzealous extension. Here's how to fix it step by step:

1. Disable Suspicious Formatting Extensions

First, let's rule out third-party extensions that might be overriding your formatting:

  • Open the Extensions panel with Ctrl+Shift+X.
  • Search for extensions related to formatting (like Prettier, ESLint, or any "list formatter" tools).
  • Temporarily disable each one, save your file again, and check if the problem goes away.
  • If you find the culprit, adjust its settings: either turn off "Format On Save" for that extension, or exclude your file type (e.g., plain text) from its formatting rules.

2. Tweak VS Code's Built-In Formatting Settings

If extensions aren't the issue, check the editor's core settings:

  • Open the Settings UI with Ctrl+,.
  • Search for Editor: Format On Save and uncheck the box. Save your file to test if the multi-line format stays intact.
  • If you still want formatting for other file types but not your current one, create a file-specific rule:
    • Open your settings.json file by pressing Ctrl+Shift+P and selecting "Open Settings (JSON)".
    • Add this snippet (replace plaintext with your file type if needed, like markdown):
      "[plaintext]": {
          "editor.formatOnSave": false
      }
      

3. Verify Keyboard Shortcuts

Double-check that Ctrl+S isn't bound to any unexpected commands:

  • Open the Keyboard Shortcuts panel with Ctrl+K Ctrl+S.
  • Search for "save" and ensure Ctrl+S only maps to the files.save command. Remove any conflicting bindings if you find them.

4. Check for Auto-List Formatting

Since your saved text is getting numbered (1., 2., 3.), there might be an extension that automatically converts multi-line text into ordered lists. Look for extensions with names like "List Tools" or "Auto List Format" and disable them to test.

Once you've gone through these steps, your multi-line text should stay as-is when you save it in VS Code!

内容的提问来源于stack exchange,提问作者user12456188

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:48:18