1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vimでshift-jisからutf-8へ変換

Last updated at Posted at 2018-07-23

Vim でwindowsで書かれたファイル(shift-jis)をmacやlinuxで開くと文字化けする。
これをutf-8に変換する。
まずは普通にVimでファイルを開く。コマンドモードで以下のコマンドを順番に入力する。

#shift-jisで表示する
:e ++enc=shift-jis
#utf-8に変換
:set fenc=utf-8
#改行コードをLFに変換
:e ++ff=unix
#改行コードに^Mが表示されるので(CRLF)、^Mを削除してLFにする
:%s/^M//g

^MはCtrl+V + Ctrl+M

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?