Dot Anything


中文文档
Highlights
⭐ Type what you think, the moment you think it.
╭──────────────────────────╮
│ 💭 Want to output name? │
╰──────────┬───────────────╯
○
○
{\_/}
( •.•)
/ >
😫 Traditional Snippet 😊 Dot Anything
{\_/} {\_/}
( -_-) name → clg → name ( ^.^) name.log
/ > 🔄 Context switch ×2 / > ✨ Zero interruption
⭐ Not just template substitution — programmable snippets.
╭───────────────────────────────────────╮
│ 💭 What if snippets had functions? │
╰──────────┬────────────────────────────╯
○
○
{\_/}
( •.•)
/ >
📦 VS Code Snippets 🚀 Dot Anything
{\_/} {\_/}
( -_-) key → template → code ( ^.^) key → fn(env):template → code
/ > 📋 Static / > 🧩 Programmable = ∞
Press . to transform text into anything. Not just template substitution — supports JavaScript functions for programmable snippets.
Table of Contents
Quick Start

| Description | Config | Example |
| Insert console.log (with file location) |
{
"dot-anything.rules": [
{
"trigger": "log",
"description": "Insert console.log (with file location)",
"snippet": "console.log('🖨️ #filePath#[#lineNumber#:#column#] #word^toKebabCase#:', #word#);"
}
]
} |
HelloWorld.log →console.log('🖨️ /home/demo.js[15:12] hello-world:', HelloWorld); |
→ More common configurations
Configuration
Configure dot-anything.rules in VS Code settings. Each rule has the following properties:
⚠️ Setting this will override the default rules. See Default Rules to copy them back.
| Property |
Type |
Required |
Default |
Description |
trigger |
string |
Yes |
- |
Trigger keyword |
description |
string |
No |
- |
Description (supports Markdown) |
snippet |
string | string[] |
Yes |
- |
Template string or function (supports array form) |
type |
text | function |
No |
text |
Rule type |
fileType |
string[] |
No |
["*"] |
Language identifiers (e.g., ["javascript"]) |
replaceMode |
word | line | file |
No |
word |
Replacement scope (word / line / file) |
pattern |
string |
No |
(\S+)$ |
Custom trigger regex (trailing . stripped) |
text Mode (Default)
Use #variable^formatFunction# placeholder syntax:
| Description | Config | Example |
| Insert console.log |
{
"trigger": "log",
"description": "Insert console.log",
"fileType": ["javascript", "typescript"],
"snippet": "console.log('#word^toUpperCase#', #word#)"
} |
abc.log → console.log('ABC', abc) |
function Mode
Use JavaScript arrow functions for complex transformations:
| Parameter |
Description |
env |
Environment object (env.word, env.fileName, etc.) |
fns |
Formatting utilities (fns.toCamelCase, etc.) |
| Description | Config | Example |
| Insert console.log with file info |
{
"trigger": "log",
"description": "Insert console.log with file info",
"type": "function",
"snippet": "(env, { fns }) => `console.log('[${env.fileName}:${env.lineNumber}] ${fns.toUpperCase(env.word)}:', ${env.word})`"
} |
abc.log →console.log('[demo:23] ABC:', abc) |
Generate getter/setter methods (array multiline form) |
{
"trigger": "getter",
"description": "Generate getter/setter methods",
"type": "function",
"snippet": [
"(env, { fns }) => `\\",
"{",
" _${env.word}: 1,",
" get ${fns.toPascalCase(env.word)}() {",
" return this._${env.word};",
" },",
" set ${fns.toPascalCase(env.word)}(v) {",
" this._${env.word} = v;",
" }",
"}`"
]
} |
abc.getter →{
_abc: 1,
get Abc() {
return this._abc;
},
set Abc(v) {
this._abc = v;
}
} |
Template Syntax
Environment Variables
Referenced via #variableName# in text mode, or env.variableName in function mode.
| Variable |
Description |
word |
Input text (before .) |
match |
Regex capture groups array |
filePath |
Full file path |
fileName |
File name (no extension) |
fileBase |
File name (with extension) |
fileExt |
File extension |
fileDir |
File directory |
languageId |
Language identifier |
lineNumber |
Current line number |
column |
Current column number |
lineText |
Current line text |
workspaceFolder |
Workspace folder path |
Used via ^functionName suffix in text mode (e.g., #word^toUpperCase#), or fns.functionName() in function mode.
| Function |
Description |
Example |
| (no suffix) |
Keep original value |
helloWorld → helloWorld |
toLowerCase |
All lowercase |
HELLO → hello |
toUpperCase |
All uppercase |
hello → HELLO |
toUpperCaseFirst |
Capitalize first letter only |
hello world → Hello world |
toCapitalize |
Capitalize first, lowercase rest |
hello World → Hello world |
toTitleCase |
Capitalize first letter of each word |
hello world → Hello World |
toKebabCase |
Hyphen-joined, all lowercase |
HelloWorld → hello-world |
toSnakeCase |
Underscore-joined, all lowercase |
HelloWorld → hello_world |
toCamelCase |
camelCase |
hello-world → helloWorld |
toPascalCase |
PascalCase |
hello-world → HelloWorld |
Advanced Features
Cursor Placeholder (Tab Jump)
Use #✏️# syntax in snippets to define editable positions with Tab navigation and automatic format conversion.
Syntax: #✏️<index>^<modifier>-<comment>#
| Part |
Required |
Description |
<index> |
Yes |
Tab order (starting from 1) |
<modifier> |
No |
Format function applied when leaving |
<comment> |
No |
Default value / hint text |
| Description | Config | Example |
| Generate const declaration |
{
"trigger": "const",
"description": "Generate const declaration",
"snippet": "const #✏️1^toUpperCase-name# = #✏️2-value#;"
} |
Type myVar.const → Insert const name = value; → Edit name to myvar → Press Tab → auto-converts to MYVAR |
With custom functions Multiple naming styles |
{
"dot-anything.rules": [
{
"trigger": "cases",
"description": "Show multiple naming styles",
"snippet": "camel: #✏️1^toCamelCase#, hook: #✏️1^reactHook#"
}
],
"dot-anything.fns": [
{
"name": "reactHook",
"fn": "(s = '', { fns }) => `use${fns.toUpperCaseFirst(s)}`"
}
]
} |
Type demo.cases → Edit to hello world → Press Tab →
camel: helloWorld
hook: useHello world |
Note: Placeholders with the same index share the same default value (VS Code limitation), but each position can have a different modifier, applied separately when leaving.
Replace Mode (replaceMode)
Control the scope of text replaced when a completion is accepted:
| Value |
Replacement Scope |
Example (input abc def., result DEF) |
word |
Nearest word only |
abc DEF |
line |
Entire line |
DEF |
file |
Entire file |
Entire file content replaced |
| Description | Config | Example |
| Comment out the entire line |
{
"trigger": "//",
"description": "Comment out the whole line",
"pattern": "",
"replaceMode": "line",
"snippet": "// #lineText#"
} |
Line abc def →// abc def |
The formatted result is unchanged regardless of replaceMode. Only the replacement range changes. Default is word, fully backwards-compatible.
Pattern Matching (pattern)
By default, rules match non-whitespace text before . ((\S+)$). Use pattern to customize the trigger regex per rule.
Empty pattern — trigger without input: Set "pattern": "" to trigger by just typing ..
| Description | Config | Example |
Convert number to px (digits only) |
{
"trigger": "px",
"description": "Convert number to px",
"pattern": "(\\d+)$",
"snippet": "#word#px"
} |
16.px → 16px (non-digits won't trigger) |
Swap two words (capture groups) |
{
"trigger": "swap",
"description": "Swap two words",
"pattern": "(\\w+)\\s+(\\w+)$",
"snippet": "#match.2# #match.1#"
} |
hello world.swap → world hello |
Access capture groups via match:
| Syntax |
Description |
Example (pattern (hello) (world)) |
#match# |
All groups joined by comma |
hello world,hello,world |
#match.N# |
Specific capture group |
#match.1# → hello |
#match.N^format# |
Capture group + format func |
#match.1^toUpperCase# → HELLO |
env.match[N] |
Access in function mode |
env.match[2] → world |
File Type Filter (fileType)
Limit rules to specific languages:
| Description | Config | Example |
| Insert print (Python only) |
{
"trigger": "print",
"description": "Insert print",
"fileType": ["python"],
"snippet": "print('#word#', #word#)"
} |
data.print → print('data', data) |
Common identifiers: * (all), javascript, typescript, python, java, go, rust, html, css, json, markdown — Full list
Custom Functions
Configure custom formatting functions via dot-anything.fns, available in both text and function modes:
{
"dot-anything.fns": [
{
"name": "prefix",
"fn": "(s) => 'prefix_' + s"
},
{
"name": "wrap",
"fn": "(s, { fns }) => `{{${fns.toUpperCase(s)}}}`"
}
]
}
| Description | Config | Example |
| text mode — Add prefix |
{
"trigger": "prefix",
"description": "Add prefix",
"snippet": "#word^prefix#"
} |
hello.prefix → prefix_hello |
| function mode — Generate React Hook name |
{
"dot-anything.rules": [
{
"trigger": "hook",
"type": "function",
"description": "Generate React Hook name",
"snippet": "(env, o) => o.fns.reactHook(env.word, o)"
}
],
"dot-anything.fns": [
{
"name": "reactHook",
"fn": "(s, { fns }) => `use${fns.toUpperCaseFirst(s)}`"
}
]
} |
state.hook → useState |
| Parameter |
Description |
s |
Input string |
fns |
Built-in formatting functions (e.g., fns.toUpperCase) |
Note: When calling custom functions in function mode, you must pass through the second parameter o (containing fns), otherwise the custom function cannot access built-in functions internally. Custom functions override built-in functions with the same name.
Debug & Development
Debug mode:
{ "dot-anything.debug": true }
Requirements: Node.js 22.x, VS Code 1.103.0+
npm run compile # Development build
npm run watch # Watch mode
npm run package # Production build
npm test # Run tests
Press F5 to launch Extension Development Host for debugging.
License
See LICENSE.txt.
Feedback & Contributing

| |