When vim edits the file, it prompts the solution of Found a swap file by the name ".start.sh.swp"
1. Problem description
When vim edits the file, it prompts Found a swap file by the name “.start.sh.swp”, as shown in the following figure:
2. Reasons
When the file is abnormally interrupted (abnormal exit, such as unexpected shutdown, directly closing the Shell terminal, etc.), a ***.swp file will be generated in the current directory. In Linux, files starting with . are hidden files, which can be viewed by using ll -a or ls -a. This swp file is a hidden file and has two functions:
- Avoid producing two different versions when editing the same file with multiple programs.
- Files are restored on unusual exits.
3. Solutions
3.1 Solution 1 can be deleted
If the temporary file is what we need, use vim -r filename or follow the prompts to repair it; if the temporary file is not needed, just delete it directly.
3.2 Solution 2 Prohibit generating swp files
If you want to prohibit the generation of swp files, you can do so by modifying the configuration file of vim. Create a new ~/.vimrc file and add a line of code to the file:
set noswapfile
Note: This configuration will only take effect for the current user.
This article is over!