1. Enter the command mode. In the command mode of VIM, enter ":" In edit mode. The cursor jumps to the last line of the screen and displays the colon. Now the command mode is started.
The command mode is displayed on the last line of the screen. Press enter and run the command in vim.
2. Enter the following characters in command mode:: % S/^ m $/g
3. Press enter. All ^ m characters in the file are automatically deleted.
Run the following command to delete spaces at the end of a line: % S/\ s \ + $ //
What exactly does this command mean? % Indicates matching the entire file. s indicates replacement. ^ m Note: use Ctrl + V Ctrl + m to input. $ after M indicates matching the content at the end of a line, the final G indicates that all matched content in each line must be replaced. After understanding the meaning of the command, you can use it as a work und. For example, if you want to replace all Vim in a file with vim, you can use this command:: % S/Vim/g
.
Vim Delete ^ m