如何在Visual Studio Code中设置COBOL的tabStops?
Hey there! I totally get this frustration—COBOL’s fixed format relies on those specific tab stops (6,7,8,12,72) for proper alignment, and it’s annoying when the default single tabSize setting doesn’t cut it. Let’s walk through exactly how to set this up, depending on the COBOL extension you’re using:
Step 1: Identify Your COBOL Extension
First, confirm which VS Code COBOL plugin you have installed—most popular ones support multi-column tab stops, but the setting names vary a bit:
For IBM Z Open Editor (Most Common for Enterprise COBOL)
- Open VS Code settings (press
Ctrl+,on Windows/Linux,Cmd+,on Mac) - In the search bar, type
ibmz-open-editor formatting tab stops - You’ll see a field labeled IBM Z Open Editor > Formatting: Tab Stops—enter your desired values as a comma-separated list:
6,7,8,12,72 - Save the settings, and open a fixed-format COBOL file to test: pressing Tab should jump to the next specified column.
For Micro Focus COBOL Extension
- Open settings and search for
cobol editor tab stops - Look for the COBOL > Editor: Tab Stops setting, then input your comma-separated values:
6,7,8,12,72
Step 2: Manual JSON Configuration (If You Prefer)
If you’d rather edit the settings.json file directly (sometimes faster for power users):
- Open the command palette with
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) - Select Preferences: Open Settings (JSON)
- Add the appropriate line based on your extension:
- For IBM Z Open Editor:
"ibmz-open-editor.formatting.tabStops": [6,7,8,12,72] - For Micro Focus COBOL:
"cobol.editor.tabStops": [6,7,8,12,72]
- For IBM Z Open Editor:
- Save the file, and your tab stops will take effect immediately.
Important Note: Fixed Format Mode
Make sure your COBOL file is set to Fixed Format (not Free Format)—multi-column tab stops only apply to fixed-format COBOL. You can check/switch this in the bottom-right corner of the VS Code window (look for the file format label, e.g., COBOL (Fixed)).
If You Still Can’t Find the Setting
- Update your COBOL extension to the latest version—older versions might not have this feature.
- Double-check that you’re looking in the extension-specific settings, not the general VS Code
editor.tabSize(which only controls single-tab width, not multi-column stops).
内容的提问来源于stack exchange,提问作者Morepork

