├── .gitignore ├── Context.sublime-menu ├── Default (Linux).sublime-keymap ├── Default (OSX).sublime-keymap ├── Default (Windows).sublime-keymap ├── HTMLNestComments.py ├── HTMLNestComments.sublime-commands ├── LICENSE ├── Main.sublime-menu ├── README.md ├── messages.json ├── messages └── install.txt └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.exe 7 | *.o 8 | *.so 9 | *.sass-cache 10 | 11 | # Packages # 12 | ############ 13 | # it's better to unpack these files and commit the raw source 14 | # git has its own built in compression methods 15 | *.7z 16 | *.dmg 17 | *.gz 18 | *.iso 19 | *.jar 20 | *.rar 21 | *.tar 22 | *.zip 23 | 24 | # Logs and databases # 25 | ###################### 26 | *.log 27 | *.sql 28 | *.sqlite 29 | 30 | # OS generated files # 31 | ###################### 32 | .DS_Store 33 | .DS_Store? 34 | ._* 35 | .Spotlight-V100 36 | .Trashes 37 | Icon? 38 | ehthumbs.db 39 | Thumbs.db 40 | 41 | # Custom # 42 | ###################### 43 | *.eot 44 | *.woff 45 | *.ttf 46 | *.otf 47 | *.sublime-workspace 48 | *.sublime-project 49 | .sass-cache 50 | *.tasks -------------------------------------------------------------------------------- /Context.sublime-menu: -------------------------------------------------------------------------------- 1 | [{ 2 | "caption": "HTML Nest Comments", 3 | "children": [{ 4 | "caption": "Comment/Uncomment Selection", 5 | "command": "nest" 6 | }] 7 | }] 8 | -------------------------------------------------------------------------------- /Default (Linux).sublime-keymap: -------------------------------------------------------------------------------- 1 | [{ 2 | "keys": ["ctrl+shift+/"], 3 | "command": "nest" 4 | }] 5 | -------------------------------------------------------------------------------- /Default (OSX).sublime-keymap: -------------------------------------------------------------------------------- 1 | [{ 2 | "keys": ["super+shift+/"], 3 | "command": "nest" 4 | }] 5 | -------------------------------------------------------------------------------- /Default (Windows).sublime-keymap: -------------------------------------------------------------------------------- 1 | [{ 2 | "keys": ["ctrl+shift+/"], 3 | "command": "nest" 4 | }] 5 | -------------------------------------------------------------------------------- /HTMLNestComments.py: -------------------------------------------------------------------------------- 1 | import sublime, sublime_plugin 2 | 3 | class NestCommand(sublime_plugin.TextCommand): 4 | def run(self, edit): 5 | for region in self.view.sel(): 6 | if region.empty(): 7 | continue 8 | text = self.view.substr(region) 9 | if text.startswith("') 15 | self.view.replace(edit, region, text) 16 | else: 17 | # comment the nested comments 18 | text = text.replace('', '~~>') 20 | self.view.replace(edit, region, text) 21 | self.view.insert(edit, self.view.sel()[0].begin(), "") 23 | -------------------------------------------------------------------------------- /HTMLNestComments.sublime-commands: -------------------------------------------------------------------------------- 1 | [{ 2 | "caption": "HTML Nest Comments: Comment/Uncomment Selection", 3 | "command": "nest" 4 | }] 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Phil Sinatra 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Main.sublime-menu: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": "preferences", 3 | "children": [{ 4 | "id": "package-settings", 5 | "children": [{ 6 | "caption": "HTML Nest Comments", 7 | "children": [{ 8 | "caption": "Comment/Uncomment Selection", 9 | "command": "nest" 10 | }] 11 | }] 12 | }] 13 | }] 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![GitHub tag](https://img.shields.io/github/tag/philsinatra/HTML-Nest-Comments.svg?style=flat-square)](https://github.com/philsinatra/HTML-Nest-Comments) 2 | [![Package Control](https://img.shields.io/packagecontrol/dt/HTML%20Nest%20Comments.svg?style=flat-square)](https://packagecontrol.io/packages/HTML%20Nest%20Comments) 3 | [![license](https://img.shields.io/github/license/philsinatra/HTML-Nest-Comments.svg?style=flat-square)](https://github.com/philsinatra/HTML-Nest-Comments/blob/master/LICENSE) 4 | 5 | # HTML Nest Comments for Sublime Text 6 | 7 | ## About 8 | This is a Sublime Text 2 and 3 plugin allowing you to quickly comment out blocks of HTML code that already contain HTML comments. 9 | 10 | ![example image](http://cdn.philsinatra.com/libraries/sublime-text/html-nested-comments/sublime-nested-comments.gif) 11 | 12 | ## Installation 13 | The easy way is: 14 | 15 | ### Through [Sublime Package Manager](http://wbond.net/sublime_packages/package_control) 16 | 17 | * Ctrl+Shift+P or Cmd+Shift+P in Linux/Windows/OS X 18 | * type `install`, select `Package Control: Install Package` 19 | * type `htmlnest`, select `HTML-Nest-Comments` 20 | 21 | ### Manually 22 | Make sure you use the right Sublime Text folder. For example, on OS X, packages for version 2 are in `~/Library/Application\ Support/Sublime\ Text\ 2`, while version 3 is labeled `~/Library/Application\ Support/Sublime\ Text\ 3`. 23 | 24 | These are for Sublime Text 3: 25 | 26 | #### Mac 27 | `git clone https://github.com/philsinatra/HTML-Nested-Comments.git ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/HTML-Nest-Comments` 28 | 29 | #### Linux 30 | `git clone https://github.com/philsinatra/HTML-Nested-Comments.git ~/.config/sublime-text-3/Packages/HTML-Nest-Comments` 31 | 32 | #### Windows 33 | `git clone https://github.com/philsinatra/HTML-Nested-Comments.git %APPDATA%/Sublime\ Text\ 3/Packages/HTML-Nest-Comments` 34 | 35 | ## Usage 36 | Tools -> Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and type `nested`. 37 | 38 | -- or -- 39 | 40 | Ctrl+Shift+/ (or Cmd+Shift+/ if you're on a Mac). 41 | 42 | -- or -- 43 | 44 | Right click in the current buffer and select `HTML Nest Comments` -> `Comment/Uncomment Selection`. 45 | 46 | -- or -- 47 | 48 | Open an HTML file, pop out the console in Sublime Text from View -> Show Console, and type `view.run_command("nest")`. 49 | 50 | Writing commands in the console is ugly. Set up your own key combo for this, by going to Preferences -> Key Bindings - User, and adding a command in that array: `{ "keys": ["super+shift+/"], "command": "nest" }`. You can use any other command you want, thought most of them are already taken. 51 | 52 | ## What Happens 53 | The built in comment function in Sublime Text runs into an issue if your HTML code contains comments that you want to maintain while block commenting larger areas of code. This plugin will temporarily disable the nested comments so that you can bulk comment out blocks of HTML that already contain comments. 54 | 55 | ```html 56 |
57 |
58 |
59 | 60 | 61 |
62 | 63 |
64 | 65 | ``` 66 | 67 | Each of the existing comment tags will be replaced with `` respectively when commenting, and then the effect will be reversed when uncommenting. 68 | 69 | Run the nest command and the code is transformed into: 70 | 71 | ```html 72 | 82 | ``` 83 | -------------------------------------------------------------------------------- /messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "install": "messages/install.txt" 3 | } 4 | -------------------------------------------------------------------------------- /messages/install.txt: -------------------------------------------------------------------------------- 1 | HTML Nest Comments 2 | ------------------ 3 | 4 | You can now nest HTML comments like a pro. 5 | 6 | Documentation and usage is available on Github: 7 | https://github.com/philsinatra/HTML-Nest-Comments 8 | 9 | If you encounter a bug or want to contribute, please open an issue: 10 | https://github.com/philsinatra/HTML-Nest-Comments/issues 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "HTML-Nest-Comments", 3 | "description": "This is a Sublime Text 2 and 3 plugin allowing you to quickly comment out blocks of HTML code that already contain HTML comments", 4 | "version":"1.0.1", 5 | "repository": { 6 | "type": "git", 7 | "url": "git@github.com:philsinatra/HTML-Nest-Comments.git" 8 | }, 9 | "author": "Phil Sinatra", 10 | "license": "MIT", 11 | "bugs": { 12 | "url": "https://github.com/philsinatra/HTML-Nest-Comments/issues" 13 | }, 14 | "homepage": "https://github.com/philsinatra/HTML-Nest-Comments" 15 | } 16 | --------------------------------------------------------------------------------