How to set noexpandtab for a specific file

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to set noexpandtab for a specific file

Bradley Bell
I have the following two lines in my .vimrc:
  :set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
  set modeline

On the first line of a file called automake.am, I have
  # vim: set noexpandtab:

When I open automake.am and enter a tab I spaces instead of tabs.

How do I set noexpandtab for automake.am automatically, so I do
not forget to enter it every time I edit that file ?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Kit
Reply | Threaded
Open this post in threaded view
|

Re: How to set noexpandtab for a specific file

Kit
2018-11-24 15:46 GMT+01:00, Bradley Bell <[hidden email]>:
> How do I set noexpandtab for automake.am automatically, so I do
> not forget to enter it every time I edit that file ?

~/.vim/ftplugin/automake.vim:
set noexpandtab
--
Kit

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to set noexpandtab for a specific file

Gary Johnson-4
On 2018-11-24, Kit wrote:
> 2018-11-24 15:46 GMT+01:00, Bradley Bell <[hidden email]>:
> > How do I set noexpandtab for automake.am automatically, so I do
> > not forget to enter it every time I edit that file ?
>
> ~/.vim/ftplugin/automake.vim:
> set noexpandtab

Vim doesn't set the filetype of a file named automake.am to
"automake", it sets the filetype to "elf".  The OP may have to add
an overriding rule to set the filetype of automake.am to "automake".

The OP's modeline should work.  It would be nice to find out why it
doesn't.  Executing

    :verbose set expandtab?

may give a clue.

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to set noexpandtab for a specific file

Erik Christiansen
In reply to this post by Bradley Bell
On 24.11.18 06:46, Bradley Bell wrote:
> I have the following two lines in my .vimrc:
>   :set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
>   set modeline
>
> On the first line of a file called automake.am, I have
>   # vim: set noexpandtab:

It works for me in makefiles, using:

# vim:noexpandtab list

The "set" isn't mandatory, but that should work just as well.
The "list" is just to show the tabs, for good measure.

That just leaves the second colon to be removed.

Erik

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to set noexpandtab for a specific file

Ben Fritz
In reply to this post by Bradley Bell
On Saturday, November 24, 2018 at 3:20:32 PM UTC-6, Bradley Bell wrote:

> I have the following two lines in my .vimrc:
>   :set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
>   set modeline
>
> On the first line of a file called automake.am, I have
>   # vim: set noexpandtab:
>
> When I open automake.am and enter a tab I spaces instead of tabs.
>
> How do I set noexpandtab for automake.am automatically, so I do
> not forget to enter it every time I edit that file ?
Is your 'modeline' option set? Some Linux distros disable modelines in a system vimrc, for security reasons. If 'modeline' is not turned on, then your method will not work.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.