A programmer used vim to view production files, and was scolded by Party A for this reason

Mondo Technology Updated on 2024-01-29

In the process of processing production environment files, aProgrammerusevimto view the contents of the file. However, when this behavior was seen by Party A, Party A severely criticized him and asked him if he wanted to change the file configuration. To this, this oneProgrammerIndicates that he just wants to browse the contents of the file and has no other intentions. This incident has aroused heated discussions among many netizens, some people think that Party A is too fussy and uses chicken feathers as an arrow, if you are really worried about the file being tampered with, you should set up permissions, instead of accusing him of using itvimView the file. In addition, if you do not save the file when you close it, you can avoid changing the configuration by mistake. However, there are also many netizens who agree with Party A's view, believing that good Xi should be developed when handling production documents and should not be usedvimFeel free to open it and view it. ExactlyvimWhat's the difference with view?Why use with cautionvim?These issues are further addressed below.

For Party A's use is prohibitedvimIs it just because of the fear that the file configuration will be changed?Actually, it's not all. Permission control can avoid the security risks of files being changed to a certain extent, which is also the point that many netizens refute Party A. In addition to security issues,vimThere is also a big difference in performance with view.

1. Loading speed:

Due tovimIt is a powerful text editor that can take a lot of time and system resources when opening large files, especially when the file is large and has a large number of lines. In contrast, the view asvim's read-only mode, which only needs to load the contents of the file, so it can display large files faster.

This point is also where most netizens agree with Party A's point of view, when it is usedvimWhen opening a large file, such as a log file, it is likely to be a direct resultMemory overflow, causing production accidents.

2. Memory occupation:

vimThe entire file is loaded into memory for editing, so when the file is large, it can take up a lot of memory resources. In read-only mode, the view can read the file content in a streaming mode, which only requires less memory resources.

Therefore, when working with production files, we need to carefully choose the appropriate command to view the file contents, avoid:Memory overflowand other problems.

Except for the prohibited use mentioned by Party AvimIn addition, we have several other common commands that can be used to view the contents of a file. Here's a summary of their pros and cons:

1、vim:

Advantages: Powerful, support editing and viewing files, provide rich editing functions and shortcut keys.

2. view (read-only mode of vim):

3、cat:

4、less:

Advantages: Load large files quickly, occupy less memory, and support functions such as scrolling up and down, searching, and jumping.

5、more:

6、head:

7、tail:

8、grep:

Through the above analysis, we can see that when processing production files, in addition to the view command, we can also choose cat, more, less and other commands to view the file content, but need to prohibit the usevimto avoid triggering production problems.

In reality, we need to focus not only on security, but also on system performance and stability. Therefore, when choosing the appropriate command to view the production file, you need to weigh the pros and cons according to the specific situation, and choose the command with more efficient performance and lower risk.

From this small case, we can see that in a production environment, the handling of production files needs to be done with caution. Whether it's permission control or choosing the right command to view the contents of a file, you need to consider security, performance, and stability. Therefore, we as:Programmer, to be responsible for their own operations, develop good Xi, abide by norms, ensure the stability and safety of the system in the work, and contribute to the development of the company.

Related Pages