search
HomeSystem TutorialLINUXMethods to solve the Chinese garbled problem of vim in Linux server and introduction of related parameters

linux中字符乱码解决方法介绍

Remotely logging into the Linux server and using vim to edit and view files in the terminal often encounters various English garbled problems.

The following settings can basically solve the vim English garbled problem

First check the system’s support for English

locale-a|grepzh_CN

The output sample is as follows

zh_CN.gbk

乱码怎么写_乱码复制_linux rz 乱码

zh_CN.utf8

vim can only correctly recognize English-encoded files in the list. If you need to recognize English files of other encoding types, you need to upgrade the system

vi~/.bash_profile

Add

at the end of the file

exportLANG="zh_CN.UTF-8"

乱码怎么写_乱码复制_linux rz 乱码

exportLC_ALL="zh_CN.UTF-8"

Online video tutorial recommendation: linux video tutorial

Vim encoding-related parameters:

1. eencoding is used to configure the encoding of opening files and saving files, but it can only have one value. It is only suitable for environments where a few files have the same encoding, so it is usually not used

2. Fileencodings, as you can see from the name, is an improved version of fileencoding. You can configure deepin linux with a variety of different encodings. The common configuration is that after configuration, as long as the text encoding in the list is legal, it can be For vim to read correctly, it is recommended to configure: setfileencodings=utf-bom,utf-8,gbk,gb2312,gb18030,cp936,latin1

3. Encoding, vim internal encoding, after vim reads the file, it does not process the encoding of the read file linux rz garbled code, but will convert it into the internal encoding format, this encoding It is usually related to the operating system. Most of them are utf-8 under Linux, and gdk under English windows. It is recommended to configure: setencoding=utf-8

4. termencoding, the encoding of vim output. Output refers to output to the operating system or command terminal. The default is the same as the language encoding of the operating system. If you use the linux command terminal, it is recommended that the terminal and the linux system configure the same encoding, and then configure The same termencoding, otherwise vim will not take care of shelllinux home. However, if the shell does not have an English name file, just configure the terminal and termencoding to be consistent. For windows, gbk and utf-8 can be manually identified without special Configuration, recommended configuration: settermencoding=utf-8

5. Fileformats, used to distinguish the operating system, mainly the difference between carriage return rnlinux rz garbled code, recommended configuration: setfileformats=unix,dos

Common garbled characters include the following situations:

(1) When rz files from windows environment to linux, the files appear garbled

乱码复制_乱码怎么写_linux rz 乱码

solution:

1. Use notepad++ to convert the file format to UTF-8 BOM-free format or ANSI encoding format before rz;

2.setencoding=utf-8;

(2) Garbled characters appear in secureCRT or xterm2 editing environment. Just adjust the character encoding in the session options to GB2312 or UTF-8

(3) Garbled characters appear when vim editing the log file. In most cases, it is because the format of the log file is GB2312.

乱码复制_乱码怎么写_linux rz 乱码

Solution: 1.setencoding=GB2312; 2If solution 1 does not work, adjust the secureCRT or xterm2 editing environment to GB2312

(4)wget download file name is garbled

Solution: Usually add –restrict-file-names=nocontrol, such as wget--restrict-file-names=nocontrol-m

(5) The cat file is normal, but the vim file is abnormal

Solution: Write directly to /etc/vim/vimrc, add

to the last line

setfileencodings=gb2312,utf-8

setfileencoding=gb2312

settermencoding=utf-8

The above is the detailed content of Methods to solve the Chinese garbled problem of vim in Linux server and introduction of related parameters. 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
How to Manage Firewalld and UFW for Linux SecurityHow to Manage Firewalld and UFW for Linux SecurityMay 12, 2025 am 10:56 AM

Linux systems rely on firewalls to safeguard against unauthorized network access. These software barriers control network traffic, permitting or blocking data packets based on predefined rules. Operating primarily at the network layer, they manage

How to Check If Your Linux System is a Desktop or LaptopHow to Check If Your Linux System is a Desktop or LaptopMay 12, 2025 am 10:48 AM

Determining if your Linux system is a desktop or laptop is crucial for system optimization. This guide outlines simple commands to identify your system type. The hostnamectl Command: This command provides a concise way to check your system's chassis

How to Increase TCP/IP Connections in LinuxHow to Increase TCP/IP Connections in LinuxMay 12, 2025 am 10:23 AM

Guide to adjust the number of TCP/IP connections for Linux servers Linux systems are often used in servers and network applications. Administrators often encounter the problem that the number of TCP/IP connections reaches the upper limit, resulting in user connection errors. This article will guide you how to improve the maximum number of TCP/IP connections in Linux systems. Understanding TCP/IP connection number TCP/IP (Transmission Control Protocol/Internet Protocol) is the basic communication protocol of the Internet. Each TCP connection requires system resources. When there are too many active connections, the system may reject new connections or slow down. By increasing the maximum number of connections allowed, server performance can be improved and more concurrent users can be handled. Check the current number of Linux connections limits Change settings

How to Convert SVG to PNG in Linux TerminalHow to Convert SVG to PNG in Linux TerminalMay 12, 2025 am 10:21 AM

SVG (Scalable Vector Graphics) files are ideal for logos and illustrations due to their resizability without quality loss. However, PNG (Portable Network Graphics) format often offers better compatibility with websites and applications. This guide d

How to Create Your Own Android and iOS Apps with LiveCodeHow to Create Your Own Android and iOS Apps with LiveCodeMay 12, 2025 am 10:10 AM

LiveCode: A Cross-Platform Development Revolution LiveCode, a programming language debuting in 1993, simplifies app development for everyone. Its high-level, English-like syntax and dynamic typing enable the creation of robust applications with ease

How to Reset a USB Device from the Linux TerminalHow to Reset a USB Device from the Linux TerminalMay 12, 2025 am 10:07 AM

This guide provides a step-by-step process for resetting a malfunctioning USB device via the Linux command line. Troubleshooting unresponsive or disconnected USB drives is simplified using these commands. Step 1: Identifying Your USB Device First, i

How to Set a Temporary Static IP Address on LinuxHow to Set a Temporary Static IP Address on LinuxMay 12, 2025 am 10:06 AM

Temporarily setting a static IP address on Linux is invaluable for network troubleshooting or specific session configurations. This guide details how to achieve this using command-line tools, noting that the changes are not persistent across reboots

51 Lesser-Known Linux Commands for Power Users51 Lesser-Known Linux Commands for Power UsersMay 12, 2025 am 09:51 AM

Linux is known for its powerful set of command-line tools that allow users to interact with the system efficiently. While many Linux users are familiar with common commands such as ls, cd, or grep, there are also few lesser-known but extremely useful commands and shortcuts that can simplify and increase productivity. We are excited to share our latest five articles on "less known Linux commands" with over 50 commands you may not know about. You may also like: 11 little-known practical Linux commands – Part 1 10 little-known Linux commands – Part 2 10 little-known Linux commands – Part 3 10 little-known valid Linux commands

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool