How to deal with garbled Chinese characters in linux vim

藏色散人
Release: 2023-03-14 11:49:56
Original
12990 people have browsed it

Solution to Chinese garbled characters in Linux vim: 1. Edit the ".vimrc" file and add the code "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 set termencoding=utf-8 set encoding=utf-8"; 2. Execute "source .vimrc".

How to deal with garbled Chinese characters in linux vim

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

What to do if Linux vim has Chinese garbled characters?

Solution to vim garbled code under Linux: (modify the content of vimrc)

Explanation:

Generally when we edit files, we like to use WinSCP, etc. Editing with FTP software is really convenient, and sometimes vim is used to edit files directly for convenience. However, sometimes when editing files with Chinese characters, garbled characters will appear, which affects our operation. Here is a solution.

Method

1. Edit the .vimrc file

vim .vimrc
Copy after login

Add the following code:

set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
Copy after login

Save and exit. Of course, you can also use FTP software such as WinSCP. Create a new .vimrc file in the root folder and edit it.

2. The execution takes effect

source .vimrc
Copy after login

Finally, when we use vim to edit Chinese files, there will be no garbled characters.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to deal with garbled Chinese characters in linux vim. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template