Using vim for file encoding batch conversion often transmits the code in windows and linux, suffering from the encoding problem of program source code files. in windows, cp936 is used, and in linux, UTF-8 is used, when releasing the source code, you also need to separate the two types of codes...
Using vim for file encoding batch conversion often transmits the code in windows and linux, suffering from the encoding problem of program source code files. in windows, cp936 is used, and in linux, UTF-8 is used, when releasing the source code, you also need to copy two types of codes. encoding and conversion of files one by one is really a tough task. Fortunately, vim has the ability to edit files in batches, this requires the args and argdo commands. you can view: help args and: help argdo for detailed instructions. Here we will only describe the usage of these two commands for batch conversion and encoding of files: 1. set the file set, that is, the files to be operated on. wildcards can be used, for example, I usually convert the C/C ++ source code: www.2cto.com: args *. h *. cpp 2. the command to be executed on each file is provided. here is the conversion code: argdo set fenc = UTF-8 | update. this is OK and you can steal it. Note that if you want to execute multiple commands at the same time, separate them with "|". The above update must be written, because vim prompts an error when editing the next file after the file is modified and has not been saved, using this update will update the file, so that this problem will not occur. Of course, there are many things that args and argdo can do. for example, you can replace multiple files in batches. This should be very practical. for details, refer to the vim Help File: help args and: help argdo.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service