日本語 | English
PortSnippet monitors source codes and automatically generates snippets! Only for VS Code✌
VSCode saves your snippets in language-specific json files, so the snippet system in VSCode has the following drawbacks.
- Difficult to edit snippets
- Low readability
- Not cool to save snippets in a single file
PortSnippet enables us to manage snippets by multiple files and automatically generates snippets!
- Download.
- Copy these files in the same directory as PortSnippet.
- Edit the
config.json
. (Check #Config) - Run
port_snippet
! (If you use Windows, you need run as administrator)
Once you run port_snippet
, port_snippet
regiters itself as a daemon (or a Windows Service) and it will automatically start each time your computer is restarted.
Put meta tags between your code that you want to save as a snippet!
// #PORT#
// name: ""
// prefix: ""
// description: ""
// #PORT_END
PortSnippet detects these meta tags to find #PORT#
and #PORT_END#
using regex.
// #PORT#
// name: "SegmentTree"
// prefix: "seg"
// description: "セグ木"
template <class S, S (*op)(S, S), S (*e)()> struct segtree {
segtree() : segtree(0) {}
...
void update(int k) { d[k] = op(d[2 * k], d[2 * k 1]); }
};
// #PORT_END#
You need put a config file in the same directory as PortSnippet.
{
"snippets_dir": "",
"dirs": [
""
],
"files": [
""
]
}
"snippets_dir"
depends on your platform. (check this)
- Windows:
%APPDATA%\Code\User\snippets
- Mac
$HOME/Library/Application Support/Code/User/snippets
"dirs"
and "files"
means files or directories that you want to monitor.
When you change the files that PortSnippet's monitoring, it detects any changes of these files and automatically generate a snippet.
After modifing the config file, make sure to restart PortSnippet! (check #Arguments)
※ Use an ABSOLUTE path! ※
lang.json
is a JSON file for list of file extensions. You need put this file in the same directory as PortSnippet.
In Visual Studio Code, every language has a unique specific language identifier. When adding new languange, you need write identifier
for the language. Check this.
{
"lang": [
{
"name": "Rust",
"identifier": "rust",
"extension": "rs"
},
{
"name": "C",
"identifier": "c",
"extension": "c"
},
{
"name": "C ",
"identifier": "cpp",
"extension": "cpp"
},
]
}
usage: ./port_snippet [OPTION] ...
OPTION:
-m, man: run portsnippet as a foreground process.
-s, stop: stop a background portsnippet's processs.
-r, restart: restart a background portsnippet's processs.
-h, help: print this help messages.
We would love you for the contribution to PortSnippet, check the LICENSE
file for more info.
Yuiga Wada - WebSite Twitter - @YuigaWada
Distributed under the MIT license. See LICENSE
for more information.