LoginSignup
22
12

More than 5 years have passed since last update.

vimでMakefileだけTabスペースではなくTabとして入力する

Last updated at Posted at 2015-12-29

はじめてのキータ 。ω。ドウモ

Makefileで少し躓いたのでメモしておきます

Makefileでは

Makefile.make
main: main.cpp
[ tab ]g++ main.cpp

みたいに[tab]の部分はTab入力でないと機能しません
.vimrcの設定でset expandtabをしていると躓きます、ω、

解決方法1

<C-v> tabを使用する
controll + v のあとにtabキーを押します
すると普通のtabが入力されます

修正 2015/12/30

前の方法だと他のファイルに影響してたので修正しておきます

解決方法2

上の方法だと毎回<C-v>しないといけないので面倒くさいです
なので.vimrcで設定をしてあげます
編集中のファイルが'Makefile'という名前だったら
noexpandtabします

*.vimrc
let _curfile=expand("%:r")
if _curfile == 'Makefile'
  set noexpandtab
endif

自分はmakefileって名前がいい!
って人は
'Makefile'の部分を'makefile'に変更すればうまくいきます、ω、

22
12
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
22
12