Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 25 additions & 28 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "import",
"format": ["camelCase", "PascalCase"]
}
],
"rules": {
"@typescript-eslint/naming-convention": [
"warn",
{
"selector": "import",
"format": [ "camelCase", "PascalCase" ]
}
],
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": [
"out",
"dist",
"**/*.d.ts"
]
}
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/semi": "warn",
"curly": "error",
"eqeqeq": "error",
"no-throw-literal": "warn",
"no-console": "warn",
"prefer-const": "error",
"semi": "off"
},
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
}
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint-and-build:
name: Lint & Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run lint
- run: npm run compile

test:
name: Test
runs-on: ubuntu-latest
needs: lint-and-build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run compile
- name: Run tests (with virtual display)
run: xvfb-run -a npm test
38 changes: 22 additions & 16 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [

{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/extension.test"
],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
32 changes: 30 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,36 @@

All notable changes to the "format-switcher" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
Format follows [Keep a Changelog](https://keepachangelog.com/).

## [Unreleased]

- Initial release
## [0.3.0] - 2026-03-08

### Added

- **Two new formats**: `lower words` (space-separated lowercase) and `UPPER WORDS` (space-separated uppercase).
- **Cycle command** (`extension.formatSwitcher.cycleCase`) — automatically detects the current format and advances to the next in the cycle: `camelCase → snake_case → kebab-case → CONSTANT_CASE → Train-Case → lower words → UPPER WORDS → camelCase`.
- **Keyboard shortcut** `Ctrl+Shift+F` mapped to the cycle command (only active when editor has a selection, avoiding conflicts with "Find in Files").
- **Multi-cursor support** — all active selections are converted simultaneously.
- `LICENSE` file (MIT).
- GitHub Actions CI pipeline (lint → build → test).

### Changed

- Replaced `lodash` runtime dependency (~4.7 MB) with native TypeScript implementations, reducing the packaged extension size by over 95%.
- Case conversion logic extracted to a standalone `caseConverters` module for testability.
- Comprehensive unit test suite (40+ assertions) replacing the placeholder boilerplate.

### Fixed

- Context menu submenu now only appears when text is actually selected (`when: editorHasSelection`).
- Internal `CaseType` literal `'Constant case'` corrected to `'upperSnakeCase'` for consistency.

## [0.2.0] - 2024-01-01

### Added

- Initial release with five case conversions: `camelCase`, `snake_case`, `CONSTANT_CASE`, `kebab-case`, `Train-Case`.
- Right-click context menu submenu "Change case".
- `lodash` used internally for text segmentation.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 EfeDeveloper

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
73 changes: 58 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,83 @@
<img src="./images/icon.png" alt="logo" width="100" />

<h1>Format Switcher</h1>
</div>

## **Table of contents**
[![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/EdFerVIIIA.format-switcher)](https://marketplace.visualstudio.com/items?itemName=EdFerVIIIA.format-switcher)
[![CI](https://github.com/EfeDeveloper/format-switcher/actions/workflows/ci.yml/badge.svg)](https://github.com/EfeDeveloper/format-switcher/actions/workflows/ci.yml)

1. [Features](#features)
</div>

2. [Usage](#usage)
## Table of contents

3. [Requirements](#requirements)
1. [Features](#features)
2. [Installation](#installation)
3. [Usage](#usage)
4. [Keyboard Shortcut](#keyboard-shortcut)
5. [Contributing](#contributing)
6. [License](#license)

## Features

`Format Switcher` is a simple extension that allows you to change the formatting of selected text in the editor. The extension adds a new menu item to the context menu.
`Format Switcher` is a VS Code extension that transforms selected text between seven naming-convention formats via the right-click context menu or a keyboard shortcut.

The extension supports the following cases:
Supported formats:

```plaintext
CamelCase
```
camelCase
snake_case
CONSTANT_CASE
kebab-case
Train-Case
lower words
UPPER WORDS
```

- **Multi-cursor support** — all active selections are converted simultaneously.
- **Context menu** only appears when text is selected (no more silent no-ops).

## Installation

**From the Marketplace:**

1. Open VS Code
2. Press `Ctrl+P` and run: `ext install EdFerVIIIA.format-switcher`
3. Or search **"Format Switcher"** in the Extensions view (`Ctrl+Shift+X`)

**From a VSIX file:**

```
code --install-extension format-switcher-<version>.vsix
```

## Usage

![Format Switcher](./images/ExtExample.gif)
Select any text, right-click, and choose **Change case** → pick the desired format.

## Requirements
## Keyboard Shortcut

This extension uses the following libraries
Press **`Ctrl+Shift+F`** with text selected to **cycle** through formats in order:

```json
"lodash": "^4.17.21"
```
camelCase → snake_case → kebab-case → CONSTANT_CASE → Train-Case → lower words → UPPER WORDS → camelCase → …
```

The shortcut only activates when the cursor is inside the editor with a selection, so it does not conflict with the default "Find in Files" shortcut. You can customise the keybinding any time via **File → Preferences → Keyboard Shortcuts**.

## Contributing

Bug reports and feature requests are welcome — please [open an issue](https://github.com/EfeDeveloper/format-switcher/issues).

Pull requests are also welcome. To get started:

```bash
git clone https://github.com/EfeDeveloper/format-switcher.git
cd format-switcher
npm install
npm test
```

Press **F5** in VS Code to launch the Extension Development Host, or use the **"Extension Tests"** launch config to debug tests.

## License

✨**Enjoy!**
[MIT](LICENSE) © EfeDeveloper
Binary file removed images/ExtExample.gif
Binary file not shown.
Loading