Computer Setup
[Vi] change the file type between dos and unix
astrodoo
2019. 5. 10. 19:54
source: https://kb.iu.edu/d/acux
There are two methods for converting the file type between dos and unix.
1) vim, use :set ff=unix to convert to Unix; use :set ff=dos to convert to Windows.
2) show ^M and remove it:
:e ++ff=unix
It force-set the fileformat as unix without actually changing the contents.
So vim reads it like a Unix file, sees the CR characters as extra and displays them as ^M.
In vi, you can remove carriage return ( ^M ) characters with the following command:
:1,$s/^M//g
To input the ^M character, press Ctrl-v, and then press Enter or return.