├── src ├── test │ ├── index.ts │ └── extension.test.ts ├── extension.ts └── parser.ts ├── .gitignore ├── assets ├── icon.png └── remove-comments.gif ├── .vscodeignore ├── .vscode ├── extensions.json ├── settings.json ├── tasks.json └── launch.json ├── tslint.json ├── CHANGELOG.md ├── tsconfig.json ├── LICENSE ├── package.json └── README.md /src/test/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/test/extension.test.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | node_modules 3 | .vscode-test/ 4 | *.vsix 5 | -------------------------------------------------------------------------------- /assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plibither8/vscode-remove-comments/HEAD/assets/icon.png -------------------------------------------------------------------------------- /assets/remove-comments.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/plibither8/vscode-remove-comments/HEAD/assets/remove-comments.gif -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/test/** 4 | out/**/*.map 5 | src/** 6 | .gitignore 7 | tsconfig.json 8 | vsc-extension-quickstart.md 9 | tslint.json -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "eg2.tslint" 6 | ] 7 | } -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-string-throw": true, 4 | "no-unused-expression": true, 5 | "no-duplicate-variable": true, 6 | "curly": true, 7 | "class-name": true, 8 | "semicolon": [ 9 | true, 10 | "always" 11 | ], 12 | "triple-equals": true 13 | }, 14 | "defaultSeverity": "warning" 15 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | } 9 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "never" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) 5 | and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). 6 | 7 | ## Unreleased 8 | - Support for HTML 9 | 10 | ## 1.1.1 - 2018-05-05 11 | 12 | ### Changed 13 | - New icon 14 | 15 | ## 1.1.0 - 2018-05-05 16 | 17 | ### Added 18 | - Seperate commands for remove inline and multiline comments individually. 19 | 20 | ## 1.0.0 - 2018-05-04 21 | ### Added 22 | - Icon 23 | - README -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "outDir": "out", 6 | "lib": [ 7 | "es6" 8 | ], 9 | "sourceMap": true, 10 | "rootDir": "src", 11 | /* Strict Type-Checking Option */ 12 | "strict": true, /* enable all strict type-checking options */ 13 | /* Additional Checks */ 14 | "noUnusedLocals": true /* Report errors on unused locals. */ 15 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 16 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 17 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 18 | }, 19 | "exclude": [ 20 | "node_modules", 21 | ".vscode-test" 22 | ] 23 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2018 Mihir Chaturvedi 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "runtimeExecutable": "${execPath}", 13 | "args": [ 14 | "--extensionDevelopmentPath=${workspaceFolder}" 15 | ], 16 | "outFiles": [ 17 | "${workspaceFolder}/out/**/*.js" 18 | ], 19 | "preLaunchTask": "npm: watch" 20 | }, 21 | { 22 | "name": "Extension Tests", 23 | "type": "extensionHost", 24 | "request": "launch", 25 | "runtimeExecutable": "${execPath}", 26 | "args": [ 27 | "--extensionDevelopmentPath=${workspaceFolder}", 28 | "--extensionTestsPath=${workspaceFolder}/out/test" 29 | ], 30 | "outFiles": [ 31 | "${workspaceFolder}/out/test/**/*.js" 32 | ], 33 | "preLaunchTask": "npm: watch" 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | import * as vscode from 'vscode'; 2 | import { Parser } from './parser'; 3 | 4 | export function activate(context: vscode.ExtensionContext) { 5 | 6 | let activeEditor: vscode.TextEditor; 7 | let parser: Parser = new Parser(); 8 | 9 | let removeComments = function (n: number) { 10 | 11 | if (!activeEditor || !parser.supportedLanguage) { 12 | return; 13 | } 14 | 15 | if (n === 0) { 16 | parser.FindSingleLineComments(activeEditor); 17 | } 18 | else if (n === 1) { 19 | parser.FindMultilineComments(activeEditor); 20 | } else { 21 | parser.FindSingleLineComments(activeEditor); 22 | parser.FindMultilineComments(activeEditor); 23 | } 24 | 25 | vscode.workspace.applyEdit(parser.edit); 26 | }; 27 | 28 | // Register commands here 29 | 30 | let removeAllCommentsCommand = vscode.commands.registerCommand('extension.removeAllComments', () => { 31 | 32 | if (vscode.window.activeTextEditor) { 33 | activeEditor = vscode.window.activeTextEditor; 34 | parser.SetRegex(activeEditor, activeEditor.document.languageId); 35 | removeComments(2); 36 | } 37 | 38 | }); 39 | 40 | let removeSingleLineCommentsCommand = vscode.commands.registerCommand('extension.removeSingleLineComments', () => { 41 | 42 | if (vscode.window.activeTextEditor) { 43 | activeEditor = vscode.window.activeTextEditor; 44 | parser.SetRegex(activeEditor, activeEditor.document.languageId); 45 | removeComments(0); 46 | } 47 | 48 | }); 49 | 50 | let removeMultilineCommentsCommand = vscode.commands.registerCommand('extension.removeMultilineComments', () => { 51 | 52 | if (vscode.window.activeTextEditor) { 53 | activeEditor = vscode.window.activeTextEditor; 54 | parser.SetRegex(activeEditor, activeEditor.document.languageId); 55 | removeComments(1); 56 | } 57 | 58 | }); 59 | 60 | context.subscriptions.push(removeAllCommentsCommand); 61 | context.subscriptions.push(removeSingleLineCommentsCommand); 62 | context.subscriptions.push(removeMultilineCommentsCommand); 63 | 64 | } 65 | 66 | export function deactivate() { } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "remove-comments", 3 | "displayName": "Remove Comments", 4 | "description": "Remove all comments from your code at once! Unclutter and undocument your code in one go!", 5 | "version": "1.2.2", 6 | "publisher": "plibither8", 7 | "license": "MIT", 8 | "icon": "assets/icon.png", 9 | "author": { 10 | "name": "Mihir Chaturvedi" 11 | }, 12 | "homepage": "https://github.com/plibither8/vscode-remove-comments/blob/master/README.md", 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/plibither8/vscode-remove-comments" 16 | }, 17 | "bugs": "https://github.com/plibither8/vscode-remove-comments/issues", 18 | "engines": { 19 | "vscode": "^1.22.0" 20 | }, 21 | "categories": [ 22 | "Formatters" 23 | ], 24 | "keywords": [ 25 | "comment", 26 | "comments", 27 | "delete", 28 | "remove" 29 | ], 30 | "activationEvents": [ 31 | "onCommand:extension.removeAllComments", 32 | "onCommand:extension.removeSingleLineComments", 33 | "onCommand:extension.removeMultilineComments" 34 | ], 35 | "gallaryBanner": {}, 36 | "main": "./out/extension", 37 | "contributes": { 38 | "configuration": { 39 | "title": "Remove Comments configuration", 40 | "properties": { 41 | "remove-comments.multilineComments": { 42 | "type": "boolean", 43 | "default": true 44 | } 45 | } 46 | }, 47 | "commands": [ 48 | { 49 | "command": "extension.removeAllComments", 50 | "title": "Remove All Comments" 51 | }, 52 | { 53 | "command": "extension.removeSingleLineComments", 54 | "title": "Remove All Single Line Comments" 55 | }, 56 | { 57 | "command": "extension.removeMultilineComments", 58 | "title": "Remove All Multiline Comments" 59 | } 60 | ] 61 | }, 62 | "scripts": { 63 | "vscode:prepublish": "npm run compile", 64 | "compile": "tsc -p ./", 65 | "watch": "tsc -watch -p ./", 66 | "postinstall": "node ./node_modules/vscode/bin/install", 67 | "test": "npm run compile && node ./node_modules/vscode/bin/test" 68 | }, 69 | "devDependencies": { 70 | "@types/mocha": "^2.2.42", 71 | "@types/node": "^7.0.43", 72 | "tslint": "^5.8.0", 73 | "typescript": "^2.6.1", 74 | "vscode": "^1.1.26" 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🚫 Remove Comments 2 | 3 |