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

如何在Sublime Text 3中为特定语法设置默认保存扩展名(如C++设为.cc)

How to Set Default Save Extension for Specific Syntax (C++ to .cc) in Sublime Text 3

Let's break this down into two parts: first the general method for setting a default save extension for any syntax in Sublime Text 3, then the specific steps to get C++ files to default to .cc instead of the common .cpp.

General Method for Specific Syntax Default Extensions

If you want to set a default save extension for any programming language or syntax in Sublime Text 3, follow these straightforward steps:

  • First, open a file that uses the syntax you want to configure (or switch to it via View > Syntax > [Your Target Syntax]).
  • Open the syntax-specific user settings by navigating to Preferences > Settings - More > Syntax Specific - User. This will open a dedicated settings file for that syntax (it might be empty if you haven't edited it before).
  • Add the key-value pair "default_extension": "your-extension" to the JSON object. Note that you don't include the leading dot here—Sublime will handle that automatically when saving.

Specific Steps for C++ to .cc

Since the C++ standard doesn't mandate a file extension (.cpp is just the most widely adopted convention), switching to .cc is totally valid and easy to set up:

  1. Open a new file or switch an existing one to C++ syntax via View > Syntax > C++.
  2. Open the C++ syntax-specific user settings: go to Preferences > Settings - More > Syntax Specific - User. This opens C++.sublime-settings in your user config folder.
  3. Paste the following JSON into the file (if it's empty, just add this; if there are existing settings, append the line to the existing JSON object):
{
    "default_extension": "cc"
}
  1. Save the C++.sublime-settings file. From now on, any new file using C++ syntax will default to saving with the .cc extension. If you switch an existing file's syntax to C++, the save dialog will also use .cc as the default option.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.09 09:22:35