Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Edit Files using sudo or su or any other tool
VimL Visual Basic Makefile Shell
tree: 68c5b7e5fc

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
autoload
doc
plugin
.gitignore
Makefile
README
SudoEdit.vmb
todo.txt

README

*SudoEdit.txt*	Edit Files using Sudo/su

Author:  Christian Brabandt <cb@256bit.org>
Version: Vers 0.2 Mon, 14 Nov 2011 21:33:09 +0100
Copyright: (c) 2009 by Christian Brabandt 		*SudoEdit-copyright*
           The VIM LICENSE applies to SudoEdit.vim and SudoEdit.txt
           (see |copyright|) except use SudoEdit instead of "Vim".
	   NO WARRANTY, EXPRESS OR IMPLIED.  USE AT-YOUR-OWN-RISK.


==============================================================================
1. Contents				*SudoEdit* *SudoEdit-contents*

	1.  Contents......................................: |SudoEdit-contents|
	2.  SudoEdit Manual...............................: |SudoEdit-manual|
	2.1 SudoEdit: SudoRead............................: |SudoRead|
	2.2 SudoEdit: SudoWrite...........................: |SudoWrite|
	3.  SudoEdit Configuration........................: |SudoEdit-config|
        4.  SudoEdit Debugging............................: |SudoEdit-debug|
        5.  SudoEdit F.A.Q................................: |SudoEdit-faq|
	6.  SudoEdit History..............................: |SudoEdit-history|

==============================================================================
2. SudoEdit Manual					*SudoEdit-manual*

Functionality

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.

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 |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 SudoEdit Plugin provides 2 Commands:

==============================================================================
2.1 SudoRead							 *SudoRead*

	:SudoRead [file]

SudoRead will read the given file name using any of the configured methods for
superuser authtication. It basically does something like this:

:r !sudo cat file

If no filename is given, SudoRead will try to reread the current file name.
If the current buffer does not contain any file, it will abort.

SudoRead provides file completion, so you can use <Tab> on the commandline to
specify the file to read.

For compatibility with the old sudo.vim Plugin, SudoEdit.vim also supports
reading and writing using the protocol sudo: So instead of using :SudoRead
/etc/fstab you can also use :e sudo:/etc/fstab (which does not provide
filename completion)

==============================================================================
2.2 SudoWrite							 *SudoWrite*

	:[range]SudoWrite [file]

SudoWrite will write the given file using any of the configured methods for
superuser authtication. It basically does something like this:

:w !sudo tee >/dev/null file

If no filename is given, SudoWrite will try to write the current file name.
If the current buffer does not contain any file, it will abort.

You can specify a range to write just like |:w|. If no range is given, it will
write the whole file.

Again, you can use the protocol handler sudo: for writing.

==============================================================================
3. SudoEdit Configuration				*SudoEdit-config* 

By default SudoEdit will try to use sudo and if it is not found, it will try
to use su. Just because SudoEdit finds either sudo or su installed, does not
mean, that you can already use it. You might have to configure it and of
course you need to have the credentials for super-user access.

								*g:sudoAuth*

The tool to use for authentication is can be changed by setting the variable
g:sudoAuth. If this variable exists, SudoEdit will first try to use the
specified tool before falling back to either sudo or su (in that order).

For example, you could use ssh to use as authentication tool by setting
g:sudoAuth in your .vimrc as follows:

let g:sudoAuth="ssh"

							       *g:sudoAuthArg*

The variable g:sudoAuthArg specifies how to use the given authentication tool.
You can specify additional parameters that will be used. You could for example
also define here which user to change to. By default, SudoEdit will try to
become the superuser e.g. root. 

If you want to use ssh as authentication facility, you can set g:sudoAuthArg
as follows in your .vimrc:

let g:sudoAuthArg="root@localhost"

For su, you would use g:sudoAuthArg="-c", but you do not have to set it, the
plugin will automatically use -c if it detects, that su is used.

==============================================================================
4. SudoEdit Debugging					    *SudoEdit-debug*

You can debug this plugin and the shell code that will be executed by
setting:
let g:sudoDebug=1
This ensures, that debug messages will be appended to the |message-history|.


==============================================================================
5. SudoEdit F.A.Q.					    *SudoEdit-faq*

1) This plugin isn't working, while executing the same commands on the
   shell works fine using sudo.

Make sure, that requiretty is not set. If it is set, you won't be able to use
sudo from within vim.

2) The plugin is still not working!

Write me an email (look in the first line for my mail address), append the
debug messages and tell me what exactly is not working. I will look into it
and if there is a bug fix this plugin.

3) Great work!

Write me an email (look in the first line for my mail address). And if you are
really happy, vote for the plugin and consider looking at my Amazon whishlist:
http://www.amazon.de/wishlist/2BKAHE8J7Z6UW

==============================================================================
6. SudoEdit History					    *SudoEdit-history*
	0.9: (unreleased) "{{{1
	    -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!)
	0.8: Apr  20, 2010 "{{{1
	    - Made plugin autoloadable so the code is only loaded,
	      when necessary
	0.7: Oct  26, 2009 "{{{1
	    - Support for reading/writing using sudo: protocol handler
	    - Added Debugging capabilities
	0.6: July 14, 2009 "{{{1
	    - Fix minor bug, that prevents setting the filename correctly
	      when writing.
	0.5: July 08, 2009 "{{{1
	    - Enables the plugin for |GetLatestVimScripts|
	0.4: July 08, 2009 "{{{1
	    - First release
	    - Added Documentation
	0.3: July 07, 2009 "{{{1
	    - Internal version, added su support
	    - Added configuration variables
	0.2: July 07, 2009 "{{{1
	    - Internal version, Working sudo support
	    - Created plugin
	0.1: July 07, 2009 "{{{1
	    - Internal version, First working version, using simple commands

==============================================================================
Modeline: "{{{1
vim:tw=78:ts=8:ft=help:fdm=marker:fdl=0:norl
Something went wrong with that request. Please try again.