The-sflag stands for squeeze, and we use it to remove sequential occurrences of a character. 4. Usingsed sedcan also be used for removing whitespace. Liketr, thesedcommandtakes a regex approach for string manipulation. Let’s start by removing all whitespace from a string with asedregular ...
The $ EOL marker prevents the trimming of the newline character since it does not get included in the match to replace. Naturally, we can mutate the regex above for leading whitespace: :%s/^\s\+//e. To do both, we have to add some more complexity: :%s/\(^\s\+\)\|\(\s\+$...