modelineの設定を追加しておくと、他の環境に持って行った場合に規約を合わせた変更が楽になるので設定しておく。
modelineの仕様
ファイルの上下端からmodelines
オプションで設定された行数だけ、 modelineを探しに行きます。
デフォルトは上端/下端から5行以内のようです。
設定可能なオプション
option | short option | 詳細 |
---|---|---|
textwidth | tw | 設定された幅で行を改行 |
tabstop | ts | タブを画面で表示する際の幅 |
expandtab / noexpandtab | et | インデント/タブ入力時にタブではなく半角スペースとして挿入 |
shiftwidth | sw | (expandtab設定時)インデント時に使用されるスペースの数 |
softtabstop | sts | (expandtab設定時)タブを入力時にその数値分だけ半角スペースを挿入 |
wrap / nowrap | 画面端の行の折り返し設定 | |
fileformat | ff | ファイルの改行の種類 (dos, mac, unix) |
filetype | ft | ファイルタイプ (sh, python等) |
fileencoding | fenc | ファイルエンコーディング(utf-8 か shift_jis あたり) |
設定サンプル
python
python2
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix ft=python ts=4 sw=4 sts=4 si et :
python3
# ! /usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix ft=python ts=4 sw=4 sts=4 si et :
shell
bash
# vim: set ft=sh ff=unix fileencoding=utf-8 expandtab ts=4 sw=4 :