# How to save in Vim using sudo

> This is called the _tee_ vim hack. This allows you to use sudo (root) from within vim to save a file for which you don't have permissions.

- URL: https://graffino.com/til/how-to-save-a-file-in-vim-when-you-forget-to-open-with-root-permission
- Author: Nick Ciolpan
- Channel: command-line
- Published: 2018-05-08
- Updated: 2025-07-27

You can still write on a file that needs root permission, even if you forgot to open Vim with _sudo_:
```
:w !sudo tee %
```
The main trick here is using _tee_ as a hack.
