Code snippets
Framework snippets, and your own, in VS Code
Type ds- in a file and pick a controller, test, model or logger for your framework. Every bundled snippet was expanded by VS Code and then compiled, and run where the framework allows it. When you write something worth reusing, save it as your own snippet in a few seconds.
On this page 5 sections
Framework snippets
Type ds- for IntelliSense, or run DevSnip Pro: Framework Snippets to pick one from a list. They are standard VS Code snippets, so Tab moves between the placeholders.
| Language | Snippets |
|---|---|
| Java / Spring Boot | REST controller, service, JPA entity and repository, @RestControllerAdvice with ProblemDetail, configuration properties, MockMvc test (Boot 4 or 3), JUnit 5 test, SLF4J logger, record DTO |
| C# / ASP.NET Core | Minimal API endpoint group, API controller, IExceptionHandler, validated options, EF Core DbContext, [LoggerMessage], ILogger field, xUnit and WebApplicationFactory tests |
| Python | FastAPI app and router, Pydantic model, Flask route, Django view, dataclass, logging setup, pytest test, fixture and parametrize |
| TypeScript / React / Next.js | React component, data-fetching hook, context provider, Next.js page, route handler and server action, Express router and error handler, zod schema, typed fetch, Vitest and Testing Library tests |
| Dart / Flutter | Stateless and stateful widgets, FutureBuilder, JSON model, dart:developer log, widget and unit tests |
| Swift / SwiftUI | SwiftUI view, ObservableObject view model, async JSON request, os. |
For example, ds-fetch-json in a TypeScript file expands to a typed fetch wrapper that throws on non-2xx responses:
export async function fetchJson<T>(url: string, init: RequestInit = {}): Promise<T> {
const response = await fetch(url, { ...init, headers: { Accept: "application/json", ...init.headers } });
if (!response.ok) {
throw new Error(`${init.method ?? "GET"} ${url} failed: ${response.status} ${response.statusText}`);
}
return (await response.json()) as T;
}Save your own snippets
- Select the code you want to reuse.
- Run DevSnip Pro: Create Snippet from the Command Palette (Ctrl/Cmd+Shift+P).
- Enter the prefix you will type to insert it, a name and, optionally, a description for the completion list.
- Reload the window when prompted: VS Code loads snippets at startup.
Your snippets appear in IntelliSense in any of 39 languages. If a prefix is already taken, you are asked first instead of getting two snippets that pop up together. DevSnip Pro: Saved Snippets lists them and deletes the ones you no longer use.
Scaffold a whole API resource
When a snippet is too small, API Resource Scaffolder generates a validated CRUD API with pagination and 400, 404 and 409 responses for Express, NestJS, Next.js, Fastify, Spring Boot (JPA), ASP.NET Core (EF Core) or FastAPI (SQLAlchemy and Pydantic).
Tools in this area
Code & Productivity 8 tools
- Saved Snippets
- Create Snippet
- Framework Snippets
- Remove Unused Imports
- Dependencies & Installation
- Unused Dependencies
- README Viewer & Manager
- OpenCode Integration
Questions
- How do I see every DevSnip Pro snippet?
- Type ds- in a supported file to list them in IntelliSense, or run DevSnip Pro: Framework Snippets to browse and insert one from a list.
- Why does my new snippet not appear?
- VS Code loads snippets when it starts. Reload the window when DevSnip Pro prompts you, and the snippet appears in IntelliSense.
- Do the logger snippets work with Insert Debug Log?
- Yes. The ds-logger snippets for Java, C#, Python and Swift create the logger, and Insert Debug Log then writes its logs through it instead of print or System.out.println.