<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>emacs — Little Step</title>
    <link>https://rex.writeas.com/tag:emacs</link>
    <description></description>
    <pubDate>Tue, 17 Nov 2026 00:35:54 +0000</pubDate>
    <item>
      <title>Write with sudo</title>
      <link>https://rex.writeas.com/write-with-sudo?pk_campaign=rss-feed</link>
      <description>Today I learn a trick on nixCraft to save a file without root permission in vim. The simple case is like this: You want to change a confi...</description>
      <content:encoded><![CDATA[<p>Today I learn a trick on <a href="https://www.cyberciti.biz/faq/vim-vi-text-editor-save-file-without-root-permission/" rel="nofollow ugc">nixCraft </a>to save a file without root permission in vim.</p>

<p>The simple case is like this:</p>

<p>You want to change a config file using vim, and after you edit, you got a permission problem, you don&#39;t have the permission.</p>

<p>So how to keep the current edit and save the change, the simple command is <strong>:w !sudo tee %</strong>.</p>

<p>Explanation as below:</p>

<pre><code>:w – Write a file (actually buffer).
!sudo – Call shell with sudo command.
tee – The output of write (vim :w) command redirected using tee.
% – The % is nothing but current file name.
</code></pre>

<p>But what about Emacs, how do we do this in Emacs, we also got <a href="https://stackoverflow.com/questions/95631/open-a-file-with-su-sudo-inside-emacs" rel="nofollow ugc">one</a>:</p>

<pre><code>C-x C-f /sudo::/path/to/file
</code></pre>

<p>It uses Tramp module to do the same thing.</p>

<p><a href="https://rex.writeas.com/tag:vim" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">vim</span></a> <a href="https://rex.writeas.com/tag:emacs" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">emacs</span></a></p>
]]></content:encoded>
      <guid>https://rex.writeas.com/write-with-sudo</guid>
      <pubDate>Sun, 12 Dec 2021 14:27:38 +0000</pubDate>
    </item>
  </channel>
</rss>