Vim practice manual (7) about encryption

Source: Internet
Author: User
Tags uppercase letter

Reprinted please indicate from "LIU Da's csdn blog": http://blog.csdn.net/poechant

1. Encrypt Your text files

When you use Vim to open or create a file, if you add the-x parameter, that is:

vim -x filename

Then Vim will prompt you:

Enter entryption key:

After you enter the password, VIM will prompt you to repeat the input to confirm:

Enter same key again:

When you set the password, it is displayed in *, not in plaintext. When someone (including yourself) opens the file next time, VIM will prompt:

Need encryption key for "main.cpp"Enter encryption key:

In this case, you only need to enter the password you set before. If the password you entered is incorrect, VIM does not prompt you for a wrong password, but displays a bunch of meaningless junk code.

2. unencrypt and reset the password

Open the encrypted file and enter:

:set key=

In this way, your password is set to null, and you do not need to enter the password in the future. If you reset the password, you can enter:

:X

Note that X is an uppercase letter. At this time, VIM will prompt you, as long as you repeatedly enter two new passwords:

Enter entryption key: *****Enter sanme key again: *****


3. Encryption Problems

Vim's encryption function can be said to be a lot of problems. For example:

(1) If the password is incorrectly entered, VIM will not reject visitors from editing files. When the file is edited and saved in case of garbled characters, the entire file becomes messy and unrecognizable. In the future, even if you use the correct password to open the file, you will not see the correct document.

(2) If the source code file to be compiled is encrypted, it cannot pass the compiler syntax check.

(3) files cannot be encrypted. What problems does this cause? The problem is that if other users find a way to read your swap file, they can bypass the decryption link and your encryption will be meaningless. The solution is not to use swap files. There are three methods. One is to modify your vimrc file (Vim configuration file ):

set noswapfile

Second, enter the command at the beginning of opening the file with vim:

vim -x -n filename

(Note that-X is an encryption parameter. It has nothing to do with what we call swap. Do not confuse it)

Third, after entering Vim to edit the file, enter:

:setlocal noswapfile

However, the disadvantage of not switching files is that you may face the tragedy of data loss that cannot be recovered. So if you want to use encryption and do not want to lose files, you should press ": W.

Reprinted please indicate from "LIU Da's csdn blog": http://blog.csdn.net/poechant

-

Related Article

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.