Vim Shots


Using the command line mode, we construct a regular expression that will remove all whitespace characters at the end of a line.

This command looks daunting at first but we can break it down into simpler pieces:

: %s/ \s \+ $ //

The first command - : - tells vim to run the following command in command-line mode.

The next command - %s/ - says that we will find and replace the following patterns globally.

The next 3 elements \s \+ $ are the pattern to match:

So, we match one or more whitespace characters at the end of the line, and …


replace them with nothing 😀