A short while back, after exporting my blog from WordPress to Hugo I noticed that there were some weird ^M
characters in some files as shown in the following screenshot in blue.
This is a special character, CTRL+M
and can be removed using sed
or vim
. Using vim we can replace/substitute a text with the following command:
%s/MATCH-TEXT/WITH-NEW-TEXT/g
Therefore, we should be able to replace ^M
, by typing CTRL+V
then CTRL+M
, with an empty space as so:
%s/^M//g
Since I have lots of random files containing ^M
, it’d be easier to use sed
from the command line instead.
❯❯❯ sed -i 's/^M//g' *.md
-i
or--in-place
edit files in place.
For more information, you can check out the tutorial listed in the reference below.
Reference: