2
3

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エディタの行番号を表示させる(デフォルト設定あり)

Last updated at Posted at 2020-04-20

##行番号を表示する

vimエディタを開いた状態で、

:set number もしくは
:set nu

ファイルを開いている間は、行番号が表示されるようになります。

##行番号を非表示にする

vimエディタを開いた状態で、

:set nonumber もしくは
:set nonu

表示されていた行番号が、非表示になります。

##デフォルトで行番号を表示するようにする

いちいち:set numberと打つのが面倒だな・・という時は、
vimエディタの設定ファイルを編集します。

$ vi ~/.vimrc 

設定ファイルをvimエディタで開いたら、以下の一行を追記して
ファイルを保存します。

set number

これで設定は完了です。
次からvimエディタを開いた時に、自動で行番号が表示されるようになります。
なお、もともと ~/.vimrcファイルが無い場合は、新規に作成して上記の設定すれば問題ありません。

【補足】
Linuxだけでなく、Macでも同様に設定ができました。

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?