Vi/Vim prompts the worker who has no permission to save

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.