Using Scratch Files and Scratch Buffers in IntelliJ IDEA
This article explains how IntelliJ IDEA's Scratch Files and Scratch Buffers let developers quickly create temporary, language‑aware snippets for Java code, JSON, HTTP requests, HTML, CSS, SQL, XML and more, improving productivity by avoiding context switches and external editors.
When working in IntelliJ IDEA you may encounter situations such as needing to quickly write pseudo‑code, format JSON, record snippets of HTML/CSS/SQL/XML, capture ideas for another project, or log HTTP client calls. Switching to other tools can be cumbersome and may cause performance issues on low‑memory machines.
IntelliJ IDEA provides a built‑in solution called Scratch Files (temporary files) that addresses all these needs. Scratch files are not tied to any project, are stored locally (usually under a directory on the C: drive), and support full language features like syntax highlighting, code completion, and debugging.
There are also Scratch Buffers , which are simple text buffers without advanced language assistance, useful for quick notes or task lists. Up to five buffers (buffer1.txt … buffer5.txt) can be created; creating more will recycle the oldest buffer unless you rename them.
How to create a Scratch File:
Via the menu: File → New → Scratch File
Via shortcut: Ctrl+Alt+Shift+Insert
When you select code or text and press the shortcut, IDEA attempts to infer the appropriate language; if it cannot, it creates a file with the same extension as the selected content.
How to create a Scratch Buffer: Use the Find Action dialog ( Ctrl+Shift+A ) and type “new scratch buffer”.
Scratch files support most programming languages, offering syntax highlighting, code completion, and the ability to run and debug code directly from the left‑hand icon bar. They also provide local history for rollback, and can be accessed across different projects, renamed, moved, deleted, or copied.
Images in the original article illustrate the creation steps, file list, and feature screenshots; these are retained below.
For reference, the original article URL is shown below:
地址:blog.csdn.net/chenlixiao007/article/details/116431128The article concludes with a call to share the content and join a community of architects.
Java Architect Essentials
Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.