LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 01-06-2012, 09:28 PM   #1
temp2012temp
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
temp2012temp
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
electric_duckling
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

with

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


seems to work.

source: http://ppadala.net/blog/tag/tips/

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


Reply

Tags
vim



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 OpenOffice.org 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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:49 AM.

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