0

so I've recently learned about sudoedit and how I can edit a file more safely than the standard "sudo vim".

the problem is now, when I'm in vim and "vsplit" or "tabnew" I open it as my user account (no root privileges)

1
  • The sudo in sudoedit filename only works for filename; the whole point of sudoedit being to allow you to edit protected files from your regular account. Commented Dec 4, 2015 at 6:17

2 Answers 2

2

sudoedit launches a separate instance of Vim, because it has to manage the lifecycle of the editing session; i.e. write back the edited temporary file with root priviledges. It cannot achieve that from a running Vim session.

However, there are plugins that achieve sudoedit-like functionality, for example the aptly named SudoEdit.

Sign up to request clarification or add additional context in comments.

2 Comments

Eunuch is another good plugin for this
The SudoEdit plugin should allow to use :vsp sudo:///filename. (I don't use this functionality and just kept it for backwards compatibility)
0

Maybe you just want a option to save file as sudo.

You can find mapings for write file as sudo or use tpope enuch plugin.

You will get :SudoWrite and :SudoEdit commands and couple more.

vim-enuch

1 Comment

pretty much what I needed, thanks for pointing me in the right direction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.