如何使用Emacs更改文件的读/写模式? [英] How do I change read/write mode for a file using Emacs?

查看:107
本文介绍了如何使用Emacs更改文件的读/写模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果一个文件被设置为只读模式,那么如何将它改变为写入模式,反之亦然呢?

If a file is set to read only mode, how do I change it to write mode and vice versa from within Emacs?

推荐答案


Mx toggle-read-only

M-x toggle-read-only

在我的Windows框中,这相当于Alt-x打开元提示并输入toggle-read-only来调用正确的elisp函数。

On my Windows box, that amounts to Alt-x to bring up the meta prompt and typing "toggle-read-only" to call the correct elisp function.

如果使用默认键盘绑定,

If you are using the default keyboard bindings,


Cx Cq

C-x C-q

(你朗读为 Control-X Control-Q)将具有相同的效果。不过请注意,鉴于emacs基本上无限可重新配置,您的里程可能会有所不同。

(which you read aloud as "Control-X Control-Q") will have the same effect. Remember, however, given that emacs is essentially infinitely re-configurable, your mileage may vary.

从评论中追踪:缓冲区的可写状态不会更改文件的可写权限。如果您尝试写入只读文件,您将看到一条确认消息。但是,如果您拥有该文件,您可以写出您的更改,而不用更改文件的权限。

Following up from the commentary: you should note that the writeable status of the buffer does not change the writeable permission of the file. If you try to write out to a read only file, you'll see a confirmation message. However, if you own the file, you can write out your changes without changing the permissions on the file.

如果您'想要快速更改文件,而无需经过添加写入许可的多个步骤,写出更改,删除写入权限。我倾向于忘记最后一步,稍后将潜在的关键文件打开以进行意外更改。

This is very convenient if you'd like to make a quick change to a file without having to go through the multiple steps of add write permission, write out changes, remove write permission. I tend to forget that last step, leaving potentially critical files open for accidental changes later on.

这篇关于如何使用Emacs更改文件的读/写模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆