111
104

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

やべえ、root権限じゃないのにVimで保存したいファイルあるわ…

Last updated at Posted at 2013-05-29

ってことありますよね?例えば/etc/hostsとかを編集しよーっていうことでVimを立ち上げて
編集後に保存しようとしてVimに怒られた経験ありません?

そんなときは、

:w !sudo tee % > /dev/null

とすると、何もなかったかのように保存できます。

原理としては英語ですがこちらが詳しいかも。

他にはプラグインとしてSudo.vimとかSudoEdit.vimとか使うほうが
ラクちんですけども。

111
104
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
111
104

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?