Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-06-2012, 09:28 PM   #1
LQ Newbie
Registered: Jan 2012
Posts: 11

Rep: Reputation: Disabled
How to turn off expandtab for editing makefiles

To turn off expandtab for editing makefiles, put the following in your vimrc:
autocmd FileType make setlocal noexpandtab

I already put the following in my vimrc,but it didn't work when editing makefile.Vim still change tab into spaces.
Here is my vimrc,is there anything wrong ?

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
"behave mswin
syntax on
set expandtab
set tabstop=4
set shiftwidth=4
autocmd FileType make setlocal noexpandtab
set autoindent
set cindent
set nu
set diffexpr=MyDiff()
set nobackup
let &termencoding=&encoding
Old 01-07-2012, 07:34 PM   #2
LQ Newbie
Registered: Jan 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
Anyone can help me.
Thank you.
Old 01-30-2012, 11:50 AM   #3
LQ Newbie
Registered: Jan 2012
Posts: 1

Rep: Reputation: Disabled
don't know about your autocmd, but replacing

set ts=4
set sw=4
set expandtab


let _curfile = expand("%:t")
if _curfile =~ "Makefile" || _curfile =~ "makefile" || _curfile =~ ".*\.mk"
set noexpandtab
set expandtab
set tabstop=4
set shiftwidth=4

seems to work.


Last edited by electric_duckling; 01-30-2012 at 04:35 PM. Reason: solution was wrong



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how to avoid using expandtab in vim when editing makefile temp2012temp Linux - Newbie 3 01-07-2012 02:45 AM
My CnMBook Manual page 5 shows how to turn off on desk top, but how do I turn on? salmagundi Linux - Newbie 2 04-04-2009 02:46 PM
LXer: Turn into a Web-editing tool with ODF@WWW LXer Syndicated Linux News 0 08-08-2008 11:50 PM
vi expandtab darknails Linux - Software 3 01-25-2006 10:38 AM
How to turn off Xserver in the gui and turn it off in the command line geminiviper Linux - Newbie 8 08-20-2004 08:05 AM

All times are GMT -5. The time now is 07:36 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration