Home >Operation and Maintenance >CentOS >Solution to Chinese garbled code in vi in ​​centos

Solution to Chinese garbled code in vi in ​​centos

尚
Original
2020-03-19 16:52:553400browse

Solution to Chinese garbled code in vi in ​​centos

Solution to vi Chinese garbled code in centos:

Open the vimrc file and add the following code:

$vi ~/.vimrc
let &termencoding=&encoding
set fileencodings=utf-8,gbk
$:wq

Recommended tutorial: centos Tutorial

Basic knowledge of vi encoding:

1. There are 3 variables:

encoding——This option is used for buffered text (you are edited files), registers, Vim script files, etc. You can think of the ‘encoding’ option as a setting for Vim’s internal workings.

fileencoding—This option is the encoding type used by vim when writing files.

termencoding--This option represents the encoding type used for output to the client terminal (Term).

2. The default values ​​of these three variables:

encoding—the same as the current locale of the system, so the current locale must be considered when editing the file, otherwise there will be more things to set. .

fileencoding—vim automatically recognizes the encoding when opening a file, and fileencoding is the recognized value. If it is empty, the encoding will be used when saving the file. If the encoding is not modified, the value will be the current locale of the system.

termencoding——The default value is empty, that is, no encoding conversion is performed when output to the terminal.

Recommended related video tutorials: linux video tutorial

The above is the detailed content of Solution to Chinese garbled code in vi in ​​centos. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn