GitHub - lambdalisue/suda.vim: An alternative sudo.vim for Vim and Neovim
source link: https://github.com/lambdalisue/suda.vim
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
suda.vim
suda is a plugin to read or write files with sudo
command.
This plugin was built while :w !sudo tee % > /dev/null
trick does not work on neovim.
This plugin is strongly inspired by sudo.vim but the interfaces was aggressively modified for modern Vim script.
Usage
Use SudaRead
to open unreadable files like:
" Re-open a current file with sudo
:SudaRead
" Open /etc/sudoers with sudo
:SudaRead /etc/sudoers
Or SudaWrite
to write unwritable files like:
" Forcedly save a current file with sudo
:SudaWrite
" Write contents to /etc/profile
:SudaWrite /etc/profile
You can change the prompt string with g:suda#prompt
.
" 'Password' in french
let g:suda#prompt = 'Mot de passe: '
Smart edit
When let g:suda_smart_edit = 1
is written in your vimrc, suda automatically switch a buffer name when the target file is not readable or writable.
In short,
$ vim /etc/hosts
:e /etc/shadow
Will open suda:///etc/hosts
or suda:///etc/shadow
instead of /etc/hosts
or /etc/shadow
because that files are not writable or not readable.
Windows
Install mattn/sudo or gerardog/gsudo to enable this plugin in Windows.
Make sure that the following shows 1
.
: echo executable('sudo')
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK