Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set the encoding for vim

Shulou Source: shulou.com Published: 2022-06-01 16:52:12 10月05日 Update

This article mainly introduces the vim how to set the coding of the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this vim how to set the coding article, let's take a look.

View file encodings in Vim: set fileencoding

You can display the file encoding format. If you just want to view files in other encoding formats or want to solve the problem of viewing garbled files with Vim, add the following to the ~ / .vimrc file:

Set encoding=utf-8 fileencodings=utf-8

In this way, you can let vim automatically identify the file encoding (can automatically identify UTF-8 or GBK encoded files), in fact, according to the coding list provided by fileencodings to try, if you do not find a suitable encoding, use latin-1 (ASCII) coding to open. Open a file in a specified encoding, such as a file saved in ANSI in windows

Vim file.txt-c "e + + enc=GB18030" file encoding conversion

Convert file encoding directly in Vim, such as converting a file to utf-8 format

: set fileencoding=utf-8 view file format: set fileformat# or: set ff set the file format to unix:set fileformat=unix# or: set ff=unix on "how to encode vim" this article is introduced here, thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to set the code in vim". If you want to learn more knowledge, you are welcome to follow the industry information channel.

Tags: Coding document format content knowledge article automatic identification appropriate random code value just that is easy to operate article easy to understand more look industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Xiaomi vpn Apple Docker