Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pluveto/copy-code-as-markdown
A vscode extension helping you copy code with markdown fences and file name.
https://github.com/pluveto/copy-code-as-markdown
Last synced: 4 days ago
JSON representation
A vscode extension helping you copy code with markdown fences and file name.
- Host: GitHub
- URL: https://github.com/pluveto/copy-code-as-markdown
- Owner: pluveto
- License: mit
- Created: 2021-08-06T06:54:04.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-22T15:46:17.000Z (about 1 year ago)
- Last Synced: 2024-10-08T05:21:13.952Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 102 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# copy-code-as-markdown
It helps you to copy code with markdown fences and filename.
## Usage
### Basic
Execute command `copyCodeAsMarkdown: Copy selection code as Markdown`.
Your clipboard then get sth like:
````markdown
*config.yaml*
```yaml
taxonomies:
category: categories
tag: tags
series: series
author: authorsbuild:
useResourceCacheWhen: always
```
````### Switch between teplates
Execute command `copyCodeAsMarkdown: copyCodeAsMarkdown: Switch using template`.
Here are some of the builtin templates:
```jsonc
{
"default": "*{filename}* {lineNumber}:\n```{lang}\n{text}\n```",
"lineRange": "*{filename}* {lineNumber} - {lineNumberEnd}:\n```{lang}\n{text}\n```",
"onlyCode": "```{lang}\n{text}\n```",
"onlyPosition": "{filename}:{lineNumber}:{colNumber}"
}
```## Shortcut
This extension has no default shortcut. You can set it by yourself.
Edit your keybinding setting via UI,
or edit config file for example *c:\Users\\AppData\Roaming\Code\User\keybindings.json*
```jsonc
{
"key": "ctrl+shift+c",
"command": "copy-code-as-markdown.CopySelectionAsMarkdown",
"when": "editorTextFocus"
},
```## Custom template
Setting node is `copyCodeAsMarkdown.template`. Available vars:
+ `{filename}`
+ `{lineNumber}`
+ `{lineNumberEnd}`
+ `{colNumber}`
+ `{colNumberEnd}`
+ `{lang}`
+ `{text}`Example:
```jsonc
{
"copyCodeAsMarkdown.template": "```{lang}\n{text}\n```"
}
```