Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Archives
Today
Total
관리 메뉴

Astro Coke

[Vi] change the file type between dos and unix 본문

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.