# 只读文件

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com.cn/help/idea/llms.txt).

如果文件是只读的，则它会在 [状态栏](guided-tour-around-the-user-interface.html#read_only_widget)中标记为关闭的锁图标 ![锁定图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.expui.general.locked.svg)。 如果文件是可写的，它将用开放锁图标 ![解锁图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app-client.expui.general.unlocked.svg) 标记。

Procedure: 切换只读模式

* 在编辑器中打开一个文件，然后点击 [状态栏](guided-tour-around-the-user-interface.html#status-bar)中的锁图标 ![锁定图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.expui.general.locked.svg) / ![解锁图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app-client.expui.general.unlocked.svg)。

* 或者，在   项目   工具窗口（ `Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Ctrl+1` (NetBeans), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))）中选择一个文件，转到主菜单中的  `文件 | 文件属性` ，然后点击   将文件设为只读  。

![将文件设为只读](https://resources.jetbrains.com.cn/help/img/idea/2026.3/file_readonly.png)

在某些情况下，文件可能是只读的。 在这些情况下，点击状态栏中的 ![锁定图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app.expui.general.locked.svg) / ![解锁图标](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app-client.expui.general.unlocked.svg) 图标不会使文件变为可写。

* 该文件是 [反编译类](decompiler.html)。 在 IntelliJ IDEA 中，编译类通常是只读的。

* 只读状态由版本控制系统设置。 例如，文件可能被 Subversion [锁定](null)。 在这种情况下，请使用 IntelliJ IDEA 版本控制集成功能使文件可写。

* 文件大小超过 2.5 MB。 此类文件被认为过大，无法编辑。

* IntelliJ IDEA 中的库文件通常默认是只读的，因为应按原样使用其中的代码。 对于此类文件，您将不会在状态栏中看到锁图标。 IntelliJ IDEA 默认将 [Reader mode](reader-mode.html) 应用于库文件。

* 该文件不属于项目。 在这种情况下，将显示 [非项目文件保护](non-project-files-access-dialog.html)对话框，提示您选择一个操作。

* 该文件属于生成的源 ![](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app-client.expui.nodes.generatedSource.svg)或生成的测试源 ![](https://resources.jetbrains.com.cn/help/img/idea/2026.3/app-client.expui.nodes.generatedTestRoot.svg)根目录。 这些文件夹中的文件通常是只读的，因为它们是自动生成的，而不是手动编写的，并且可以重新生成。 了解有关不同类型文件夹的更多信息，请参见 [内容根](content-roots.html)。

* 该文件可能在操作系统中被标记为只读。 要检查此状态，可以查看 Windows 上的文件特性，或查看 Linux、macOS 等基于 Unix 的系统上的权限。

## See also

### 相关

[阅读模式](reader-mode.html)

