LinuxQuestions.org
Review your favorite Linux distribution.
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, 10: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, 08: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, 12:50 PM   #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 05:35 PM. Reason: solution was wrong
 
  


Reply

Tags
vim


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 03: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 03:46 PM
LXer: Turn OpenOffice.org into a Web-editing tool with ODF@WWW LXer Syndicated Linux News 0 08-09-2008 12:50 AM
vi expandtab darknails Linux - Software 3 01-25-2006 11: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 09:05 AM


All times are GMT -5. The time now is 04:01 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration