Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lambdalisue/vim-suda
🥪 An alternative sudo.vim for Vim and Neovim, limited support sudo in Windows
https://github.com/lambdalisue/vim-suda
neovim sudo vim
Last synced: 1 day ago
JSON representation
🥪 An alternative sudo.vim for Vim and Neovim, limited support sudo in Windows
- Host: GitHub
- URL: https://github.com/lambdalisue/vim-suda
- Owner: lambdalisue
- License: mit
- Created: 2017-11-24T12:41:48.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-12-06T17:03:00.000Z (6 days ago)
- Last Synced: 2024-12-06T18:24:20.759Z (6 days ago)
- Topics: neovim, sudo, vim
- Language: Vim Script
- Homepage:
- Size: 79.1 KB
- Stars: 735
- Watchers: 9
- Forks: 30
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- stars - lambdalisue/vim-suda
README
# 🥪 suda.vim
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
[![Doc](https://img.shields.io/badge/doc-%3Ah%20suda-orange.svg?style=flat-square)](doc/suda.txt)_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][].
https://github.com/neovim/neovim/issues/1716
This plugin is strongly inspired by [sudo.vim][] but the interfaces was aggressively modified for modern Vim script.
[sudo.vim]: https://github.com/vim-scripts/sudo.vim
[neovim]: https://github.com/neovim/neovim## 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`.
```vim
" '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
```or
```
: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](https://github.com/mattn/sudo) or [gerardog/gsudo](https://github.com/gerardog/gsudo) to enable this plugin in Windows.
Make sure that the following shows `1`.```vim
: echo executable('sudo')
```### Use sudo without a password
When `let g:suda#noninteractive = 1` is written in your vimrc, suda won't ask you for a password. Use at your own risk.