Skip to content

Instantly share code, notes, and snippets.

@jeremysj
Created April 28, 2019 01:33
Show Gist options
  • Save jeremysj/9303f8e3576b8c87506cf86f8bf4a10c to your computer and use it in GitHub Desktop.
Save jeremysj/9303f8e3576b8c87506cf86f8bf4a10c to your computer and use it in GitHub Desktop.

Revisions

  1. jeremysj created this gist Apr 28, 2019.
    17 changes: 17 additions & 0 deletions sudovimrc.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # Make sudo vim sane
    Using vim with something like `sudo vim /path/to/file` has historically made my head hurt. All my magic from vim-bootstrap hasn't worked. I knew why, I just didn't care enough to fix it. Until I did.

    Fix that with this simple flag:
    `sudo -E vim /path/to/some/file`

    Voilà!

    From `man sudo`:
    ```
    ...
    -E, --preserve-env
    Indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the user does not
    have permission to preserve the environment.
    ...
    ```