https://github.com/eiskrenkov/magiccomment
Fully customizable Sublime Text plugin that automatically inserts configured pragma comments for you
https://github.com/eiskrenkov/magiccomment
python sublime-package sublime-plugin sublime-text sublime-text-plugin
Last synced: about 1 year ago
JSON representation
Fully customizable Sublime Text plugin that automatically inserts configured pragma comments for you
- Host: GitHub
- URL: https://github.com/eiskrenkov/magiccomment
- Owner: eiskrenkov
- License: mit
- Created: 2022-03-12T18:50:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-31T22:05:45.000Z (about 4 years ago)
- Last Synced: 2025-04-04T01:51:04.300Z (about 1 year ago)
- Topics: python, sublime-package, sublime-plugin, sublime-text, sublime-text-plugin
- Language: Python
- Homepage: https://packagecontrol.io/packages/MagicComment
- Size: 13.7 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MagicComment ✨ for Sublime Text
MagicComment is a fully customizable Sublime Text plugin that automatically inserts required magic comments for you
Development is motivated by `frozen_string_literal` comment for Ruby files, but plugin can be used for literally any kind of files and any strings that you want to automatically insert
## Manual usage Demo

## Installation
### Package Control
MagicComment is available at [Package Control]. Just select `Package Control: Install Package` in Sublime command palette and search for `MagicComment`
### Manual Installation
- `cd ` (macOS: `~/Library/Application\ Support/Sublime\ Text/Packages`)
- `git clone https://github.com/eiskrenkov/MagicComment.git`
## Usage
- **On file save** - Enabled by default, can be disabled in settings
- **Key Bindings** - Commented by default, can be configured to anything you want
- **Command Palette** - `CMD+P` and type `MagicComment` (or just `comment`) and select `MagicComment: Insert Comments`
> You can always configure key bindings at _Sublime Text menu_ -> _Preferences_ -> _Package Settings_ -> _MagicComment_ -> _Key Bindings_
## Default Configuration
> Remember, that you can always reconfigure it, just open _Sublime Text menu_ -> _Preferences_ -> _Package Settings_ -> _MagicComment_ -> _Settings_
### General
- `run_on_save`
- Type: `Boolean`
- Default: `true`
### Comments
- `text` - Text of the comment to insert
- Type: `String`
- Default: `true`
- `line` - Number of the line you wish to insert the comment
- Type: `Integer`
- Default: `1`
- `blank_lines` - Amount of blank lines to insert after the comment
- Type: `Integer`
- Default: `0`
- `files` - Object, containing files specific settings
- Type: `Object`
- `files` -> `include` - List of file names and extensions to insert comment for
- Type: `Array` of `String`
- Default: `[]`
- `files` -> `exclude` - List of file names and extensions that you want to ignore
- Type: `Array` of `String`
- Default: `[]`
> Note, that **Include** and **Exclude** arrays support wildcards for file extensions via '*'. E.g *.rb mathes all Ruby files, *.py - all Python files and so on
### Example configuration for `#frozen_string_literal: true` for `.rb` files
```json
{
"text": "# frozen_string_literal: true",
"line": 1,
"blank_lines": 1,
"files": {
"include": ["*.rb", "Gemfile", "Rakefile", "config.ru"],
"exclude": ["schema.rb"]
}
}
```
## Contribution
Issues and pull requests are highly welcome!
[Package Control]: https://packagecontrol.io/packages/MagicComment