sponsor Vim development Vim logo Vim Book Ad

SudoEdit.vim : Edit Files using sudo or su or any other tool

 script karma  Rating 109/38, Downloaded by 2377    Comments, bugs, improvements  Vim wiki

created by
Christian Brabandt
 
script type
utility
 
description
If you like this plugin, please rate it!

This plugin enables vim to read files, using sudo or su or any other tool that
can be used for changing the authentication of a user. Therefore it needs any
of sudo or su installed and usable by the user. This means, you have to know
the credentials to authenticate yourself as somebody else.

This plugin is basically an extended version from sudo.vim
(http://www.vim.org/scripts/script.php?script_id=729), which seems to be
unmaintained now. For compatibility reasons, it also supports the sudo: protocol
handler, as sudo.vim provides.

That's why this plugin probably won't work on Windows, but you might be able
to configure it to use a method that works on Windows (see :h SudoEdit-config)

By default SudoEdit will first try to use sudo and if sudo is not found it
will fall back and try to use su. Note, that you might have to configure these
tools, before they can use them successfully.

SudoEdit requires at least a Vim Version 7 with patch 111 installed. Patch 111
introduced the shellescape() functionality.

The Plugin provides the 2 Commands :SudoRead for reading a file and SudoWrite
for writing a file using the provided super user authentication mechanism. Both
commands have file completion enabled to ease the selection of files (if you are able
to read the path as ordinary user).

You can optionally configure it to use any other tool, instead of sudo/su. So you could
probably adjust it to work on Windows or you can use ssh as authentication method.
 
install details
Edit SudoEdit.vba and source the file
:so %
is all you need. It will install the plugin and also the documentation.

I suggest you take a look at :h SudoEdit.txt before using it.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
SudoEdit-0.20.vmb 20 2014-03-27 7.4 Christian Brabandt - skip writing undo, if the buffer hasn't been written.
- document |g:sudo_tee| variable
- possibly wrong undofile was written (issue https://github.com/chrisbra/SudoEdit.vim/issues/21, reported by blueyed, thanks!)
(automatically uploaded)
SudoEdit-0.19.vmb 19 2013-08-14 7.3 Christian Brabandt - |SudoWrite| should always write if a filename has been given (issue #23, reported by Daniel Hahler, thanks!)
            - Better filename completion for |SudoWrite| and |SudoRead| commands (issue #20 reported by Daniel Hahler, thanks!)
            - Fix error in VimLeave autocommand (issue #22, reported by Daniel Hahler, thanks!)
            - reset 'shell' value (issue #24, reported by Raghavendra Prabhu, thanks!)
(automatically uploaded)
SudoEdit-0.18.vmb 18 2013-02-16 7.3 Christian Brabandt - expand() may return empty filenames (issue #17 patch by Daniel Hahler, thanks!)
- better exception handling (issue #19)
- included sudo.cmd for better usage on Windows
- enable sudo.cmd to use UAC optionally
(automatically uploaded)
SudoEdit-0.17.vmb 17 2012-08-20 7.3 Christian Brabandt - Guard against a vim without persistent_undo feature
- fix variable typo (https://github.com/chrisbra/SudoEdit.vim/pull/16 patch by NagatoPain, thanks!)
(automatically uploaded)
SudoEdit-0.16.vmb 16 2012-05-17 7.3 Christian Brabandt - Make the plugin usable on Windows |SudoEdit-Win|
(automatically uploaded)
SudoEdit-0.15.vmb 15 2012-05-08 7.3 Christian Brabandt Fix Syntax error, reported by Gary Johnson, thanks!
(automatically uploaded)
SudoEdit-0.14.vmb 14 2012-04-30 7.3 Christian Brabandt Fix issue 15 (https://github.com/chrisbra/SudoEdit.vim/issues/15, reported by Lenin Lee, thanks!)
(automatically uploaded)
SudoEdit-0.13.vmb 13 2012-04-28 7.3 Christian Brabandt - in graphical Vim, display messages, so one knows, that one needs to enter the password (reported by Rob Shinn, thanks!)
- Allow bang attribute to |SudoRead| and |SudoWrite|
- Make use of graphical dialogs for sudo to read the passwords, if possible
- Better debugging
- Code cleanup
- better filename completion with :SudoRead/SudoWrite (now also supports completing sudo: protocol handler)
(automatically uploaded)
SudoEdit-0.12.vmb 12 2012-01-31 7.3 Christian Brabandt - Avoid redraw when changing permissions of the undofile
- Don't move cursor on Reading/Writing
  (issue https://github.com/chrisbra/SudoEdit.vim/issues/11,
  reported by Daniel Hahler, Thanks!)
- Support for calling Netrw with another userid/password
  (issue https://github.com/chrisbra/SudoEdit.vim/issues/4,
  reported by Daniel Hahler, Thanks!)
- Autocmds for Writing did not fire (issue
  https://github.com/chrisbra/SudoEdit.vim/issues/10, partly by
  Raghavendra D Prabhu, Thanks!)
- Newly created files are not set 'nomodified' (issue
  https://github.com/chrisbra/SudoEdit.vim/issues/12, reported by
  Daniel Hahler, Thanks!)
- Can't create undofiles in write-protected directories (issue
  https://github.com/chrisbra/SudoEdit.vim/issues/14, reported by
  Matias Kangasjärvelä, Thanks!)
(automatically uploaded)
SudoEdit-0.11.vmb 11 2011-12-15 7.3 Christian Brabandt -change owner of undofile to that of the edited super-user file, so vim will automatically load the undofile when opening that file the next time (reported by Sean Farley and blueyed, thanks!)
-Only set the filename using :f when writing to another file (https://github.com/chrisbra/SudoEdit.vim/pull/8 and also https://github.com/chrisbra/SudoEdit.vim/issues/5 patch by Daniel Hahler, thanks!)
-fix https://github.com/chrisbra/SudoEdit.vim/issues/6 (fix permissions and path of the undofile, partly by Daniel Hahler, thanks!)
-Don't reread the file and write undofiles for empty files (https://github.com/chrisbra/SudoEdit.vim/issues/7 reported by Daniel Hahler, thanks!)
(automatically uploaded)
SudoEdit-0.10.vmb 10 2011-11-17 7.3 Christian Brabandt -fix https://github.com/chrisbra/SudoEdit.vim/issues/1 (exception 'emptyfile' not caught, reported by Daniel Hahler, thanks!)
-fix https://github.com/chrisbra/SudoEdit.vim/issues/2 (Avoid W13 error, reported by Daniel Hahler, thanks!)
-fix https://github.com/chrisbra/SudoEdit.vim/issues/3 (Write undofiles, reported by Daniel Hahler, thanks!)
(automatically uploaded)
SudoEdit.vba 0.8 2010-04-19 7.0 Christian Brabandt Make plugin autoloadable. See :h autoload-functions.
SudoEdit.vba 0.7 2009-10-26 7.0 Christian Brabandt Support for reading/writing using sudo:protocol handler
Added Debugging capabilities
SudoEdit.vba 0.6 2009-07-14 7.0 Christian Brabandt Fix minor bug, that prevents setting the filename correctly when writing.
SudoEdit.vba 0.5 2009-07-08 7.0 Christian Brabandt Minor documentation update
SudoEdit.vba 0.5 2009-07-08 7.0 Christian Brabandt Enables the plugin for |GetLatestVimScripts|
SudoEdit.vba 0.4 2009-07-08 7.0 Christian Brabandt Initial upload
ip used for rating: 54.196.195.38

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo