Vi/Vim prompts the worker who has no permission to save
Sometimes, when we use Vi/Vim to edit a file, if we do not notice the File Permission, the following error may be prompted when we finally save the file. If the user is forcibly exited, the current changes will be lost. I will share with you a method that does not need to exit and save the file.
1. In the Vi/Vim Editor, enter the colon and enter the following command:
%! Sudo tee %/dev/null
2. Enter the sudo user password:
3. After the switch is successful, enter the uppercase L key after the prompt.
4. After the file is saved successfully, enter q to exit.
Note: This operation requires that you can use the sudo command. If not, edit the sudo configuration file.
-------------------------------------- Split line --------------------------------------
Build VIM into a simple and practical IDE
Vim Learning Guide
Quick learn Vi Editor
Powerful Vim Editor
Build a Vim Development Environment on CentOS 6.2
Install the highlighted Vim editing tool in CentOS 5.4
Vim tips: C language settings
Set the Vim row number in Ubuntu
Vim editor basic tutorial
-------------------------------------- Split line --------------------------------------
This article permanently updates the link address: