In VSCodium snippets are quite easy. Browsing the docs today instead of guessing taught me a couple of cool tricks today so I think it's worth a read: https://code.visualstudio.com/docs/edit ... edsnippets
I never thought I'd be the kind of dev to get into snippets
So what do I use snippets for? One thing is to "remember" the boilerplate. It's not the kind of boilerplate I want to eliminate, that one goes away.
Code: Select all
"New editor plugin ": {
"scope": "cs,csharp",
"prefix": "editorplugin",
"body": [
"public partial class $1: EditorPlugin {",
" public void EditorLoad(Editor e) { }",
"",
" public void EditorUpdate(Editor e) { }",
"}",
],
"description": "Create a new Game Singleton"
},
Code: Select all
"Get the asset manager": {
"scope": "cs,csharp",
"prefix": "getassets",
"body": [
"var assets = Singletons.Assets();"
]
},
"Get the renderer": {
"scope": "cs,csharp",
"prefix": "getrenderer",
"body": [
"var renderer = Singletons.Renderer();"
]
},
Code: Select all
"Construct a particle": {
"scope": "cs,csharp",
"prefix": "newparticle",
"body": [
"Particle.New(",
" position: Vec2(0, 0),",
" lifetime: 1,",
" zIndex: DrawOrder.Particles.ToZ(),",
" rotation: 0f,",
" direction: Vec2(0),",
" gravity: Vec2(0),",
" speed: 0,",
" size: Vec2(1),",
" color: Color.White,",
" angularVelocity: 0f,",
" blendMode: BlendMode.AlphaBlend,",
" texture: null,",
" hFlip: false,",
" vFlip: false,",
" flipbookFrames: (numFrames: 4, fps: 12)",
")"
]
},
In the end, my dreams of a dedicated VSCode extension (which I actually have, for other more advanced use cases, but that's a story for another day) were stopped by these two lil' snippets:
Code: Select all
"Dialogue: Character": {
"scope": "xml",
"prefix": "character",
"body": [
"<character character=\"${1|lynchpin,renna,renna-hub,scientist,squatter,informant,messenger|}\" mood=\"${2|grin,happy,sigh,angry,laugh|}\"/>"
]
},
"Dialogue: Talk": {
"scope": "xml",
"prefix": "talk",
"body": [
"<talk>$1</talk>"
]
}
And you'll say: But Celes, these snippets are not in sync with your code and need manual adjustment, surely we can do better? Macros perhaps? Code generation? Well, while you were doing better I was getting the code written. That's the point of snippets. Like the blue philosopher said: "Long as the voice inside drives me to run and fight, It doesn't matter who is wrong and who is right".
Anyway, I'm glad I took the time to introduce snippets into my workflow. It took a while for me to develop the neural pathways that make my snippet sense tingle when I've been typing a recurring pattern too much, but now they're finally there