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

VS2017如何实现选中代码块自动包裹括号/引号(无需扩展)

Fixing VS2017's Selected Text Wrapping Issue (No Extensions/Shortcuts Needed)

Hey there! I totally get why this behavior is annoying—coming from editors like Atom and VS Code that automatically wrap selected text when you type quotes or braces, VS2017's default overwrite feels like a step backward. Good news: you don't need Resharper or custom shortcuts to fix this—it's a built-in setting that's just probably disabled by default.

Here's how to turn it on:

  • Open Visual Studio 2017, go to the top menu bar and select Tools > Options
  • In the Options window, expand the Text Editor section, then navigate to the language you're working with (for your C# work, that's C# > General)
  • Look for the checkbox labeled Surround selected text on typing quotes or braces (it's under the Automatic delimiter highlighting section)
  • Check that box, then click OK to save the changes

That's it! Now when you select a block of code and type quotes (", ') or braces ((), {}, []), VS2017 will wrap the selected text instead of overwriting it. If you ever use other languages in VS2017 (like Python, C++, or Go), you can repeat the same steps for their respective Text Editor > [Language] > General settings—this option exists for most supported languages.

Give it a test right away—select some code, type a quote, and you should see it wrap perfectly. No extensions, no shortcut tweaks required.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 06:45:32