简体   繁体   中英

how to open another file from within vim as a different user (sudoedit | vim )

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)

sudoedit launches a separate instance of Vim, because it has to manage the lifecycle of the editing session; ie 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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM