Skip to content

Commit e9f9451

Browse files
committed
feat: add configurable separator modes and PSV support
- add csv.resetSeparator command and improve csv.changeSeparator UX (\t support) - add quote-aware auto delimiter detection with tests and README updates
1 parent b729a2d commit e9f9451

File tree

6 files changed

+384
-38
lines changed

6 files changed

+384
-38
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Working with CSV files shouldn’t be a chore. With CSV, you get:
4242
- **Preserved CSV Integrity:** All modifications respect CSV formatting—no unwanted extra characters or formatting issues.
4343
- **Optimized for Performance:** Designed for medium-sized datasets, ensuring a smooth editing experience without compromising on functionality.
4444
- **Large File Support:** Loads big CSVs in chunks so even large datasets open quickly.
45-
- **TSV/TAB Support:** `.tsv` and `.tab` files are recognized automatically and use tabs as the default separator.
45+
- **CSV/TSV/TAB/PSV Support:** `.csv`, `.tsv`, `.tab`, and `.psv` files are recognized automatically. Defaults: comma for CSV, tab for TSV/TAB, pipe for PSV.
4646

4747
---
4848

@@ -59,9 +59,9 @@ Cursor (built on VS Code 1.99) and the latest VS Code releases (1.102).
5959
- Go to the Extensions view (`Ctrl+Shift+X` or `Cmd+Shift+X` on macOS).
6060
- Search for **CSV** and click **Install**.
6161

62-
### 2. Open a CSV, TSV, or TAB File
62+
### 2. Open a CSV, TSV, TAB, or PSV File
6363

64-
- Open any `.csv`, `.tsv`, or `.tab` file in VS Code.
64+
- Open any `.csv`, `.tsv`, `.tab`, or `.psv` file in VS Code.
6565
- The file will automatically load, presenting your data in an interactive grid view.
6666

6767
### 3. Edit and Navigate
@@ -83,6 +83,7 @@ Open the Command Palette and search for:
8383
- `CSV: Toggle First Row as Header` (`csv.toggleHeader`)
8484
- `CSV: Toggle Serial Index Column` (`csv.toggleSerialIndex`)
8585
- `CSV: Change CSV Separator` (`csv.changeSeparator`)
86+
- `CSV: Reset CSV Separator (Inherit)` (`csv.resetSeparator`)
8687
- `CSV: Change Font Family` (`csv.changeFontFamily`)
8788
- `CSV: Hide First N Rows` (`csv.changeIgnoreRows`)
8889
- `CSV: Change File Encoding` (`csv.changeEncoding`)
@@ -99,14 +100,17 @@ Global (Settings UI or `settings.json`):
99100
- `csv.columnColorMode` (string, default `type`): `type` keeps CSV’s type-based column colors; `theme` uses your theme foreground color for all columns.
100101
- `csv.columnColorPalette` (string, default `default`): Type-color palette when `csv.columnColorMode` is `type`. `cool` biases colors toward greens/blues; `warm` biases colors toward oranges/reds.
101102
- `csv.clickableLinks` (boolean, default `true`): Make URLs in cells clickable. Ctrl/Cmd+click to open links.
103+
- `csv.separatorMode` (string, default `extension`): Separator selection mode when no per-file override exists. `extension` uses extension mapping, `auto` detects from content first, `default` always uses `csv.defaultSeparator`.
104+
- `csv.defaultSeparator` (string, default `,`): Fallback separator. Use `\\t` in `settings.json` for tabs.
105+
- `csv.separatorByExtension` (object): Extension-to-separator mapping (defaults include `.csv``,`, `.tsv`/`.tab`→tab, `.psv``|`).
102106
- `csv.maxFileSizeMB` (number, default `10`): Soft limit for opening files in CSV view. If exceeded, CSV prompts: `Cancel`, `Continue This Time`, or `Ignore Forever` (sets this setting to `0`).
103107
- Per-file encoding: use `CSV: Change File Encoding` to set a file's encoding (e.g., `utf8`, `utf16le`, `windows1250`, `gbk`). The extension will reopen the file using the chosen encoding.
104108

105109
Per-file (stored by the extension; set via commands):
106110

107111
- First row as header (default `true`) — `CSV: Toggle First Row as Header`
108112
- Serial index column (default `true`) — `CSV: Toggle Serial Index Column`
109-
- CSV separator (default inherit: `.tsv`/`.tab` → tab, otherwise comma) — `CSV: Change CSV Separator`
113+
- CSV separator override — `CSV: Change CSV Separator` (or clear it with `CSV: Reset CSV Separator (Inherit)`)
110114
- Hide first N rows (default `0`) — `CSV: Hide First N Rows`
111115

112116
---

package.json

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"onCommand:csv.toggleHeader",
2626
"onCommand:csv.toggleSerialIndex",
2727
"onCommand:csv.changeSeparator",
28+
"onCommand:csv.resetSeparator",
2829
"onCommand:csv.changeFontFamily",
2930
"onCommand:csv.changeIgnoreRows",
3031
"onCommand:csv.changeEncoding",
@@ -36,11 +37,14 @@
3637
{
3738
"id": "csv",
3839
"extensions": [
39-
".csv"
40+
".csv",
41+
".psv"
4042
],
4143
"aliases": [
4244
"CSV",
43-
"csv"
45+
"csv",
46+
"PSV",
47+
"psv"
4448
],
4549
"configuration": "./language-configuration.json"
4650
},
@@ -76,6 +80,10 @@
7680
"command": "csv.changeSeparator",
7781
"title": "CSV: Change CSV Separator"
7882
},
83+
{
84+
"command": "csv.resetSeparator",
85+
"title": "CSV: Reset CSV Separator (Inherit)"
86+
},
7987
{
8088
"command": "csv.changeFontFamily",
8189
"title": "CSV: Change Font Family"
@@ -137,6 +145,34 @@
137145
"default": true,
138146
"description": "Make URLs in cells clickable. Ctrl/Cmd+click to open links."
139147
},
148+
"csv.separatorMode": {
149+
"type": "string",
150+
"enum": [
151+
"extension",
152+
"auto",
153+
"default"
154+
],
155+
"default": "extension",
156+
"description": "How CSV chooses the separator when no per-file override exists. 'extension' uses extension mapping, 'auto' attempts detection from file content first, and 'default' always uses csv.defaultSeparator."
157+
},
158+
"csv.defaultSeparator": {
159+
"type": "string",
160+
"default": ",",
161+
"description": "Fallback separator used by separator modes. Use '\\t' for tab in settings JSON."
162+
},
163+
"csv.separatorByExtension": {
164+
"type": "object",
165+
"default": {
166+
".csv": ",",
167+
".tsv": "\t",
168+
".tab": "\t",
169+
".psv": "|"
170+
},
171+
"additionalProperties": {
172+
"type": "string"
173+
},
174+
"description": "Separator mapping by file extension. Keys may be '.ext' or 'ext'. Values are separator strings."
175+
},
140176
"csv.maxFileSizeMB": {
141177
"type": "number",
142178
"default": 10,
@@ -158,6 +194,9 @@
158194
},
159195
{
160196
"filenamePattern": "*.tab"
197+
},
198+
{
199+
"filenamePattern": "*.psv"
161200
}
162201
]
163202
}

0 commit comments

Comments
 (0)