Home >Operation and Maintenance >Linux Operation and Maintenance >How to deal with garbled Chinese characters in linux vim

How to deal with garbled Chinese characters in linux vim

藏色散人
藏色散人Original
2023-03-14 11:49:5613032browse

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

Add the following code:

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

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

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!

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