[patch] sets PEP8 indenting suggestions as default in python files

110 views
Skip to first unread message

Lorenzo Bercelli

unread,
Sep 17, 2013, 5:30:28 PM9/17/13
to vim...@vim.org, joha...@zellner.org
This patch sets tabs as equal to 4 spaces in python files, as
​strongly ​
suggested by the PEP8
​ (​
http://www.python.org/dev/peps/pep-0008/#indentation
​)​
.
​​
 T
​his are probably some of the most often found options in .vimrc files, it's also the first thing suggested in all those 'create a python development environment with vim' tutorials, I think it would be easier to just make it default for python files​
.

    Lorenzo Bercelli

Lorenzo Bercelli

unread,
Sep 17, 2013, 5:36:42 PM9/17/13
to vim...@vim.org, joha...@zellner.org
Oh God sorry I forgot to attach the patch, here it is.

 
   Lorenzo
python.vim.patch

Christian Brabandt

unread,
Sep 18, 2013, 2:01:13 AM9/18/13
to vim...@googlegroups.com
On Tue, September 17, 2013 23:36, Lorenzo Bercelli wrote:
> Oh God sorry I forgot to attach the patch, here it is.

You probably want :setlocal instead of :set in the filetype plugin.

regards,
Christian

Lorenzo Bercelli

unread,
Sep 18, 2013, 8:48:12 AM9/18/13
to vim...@vim.org, joha...@zellner.org

Right, right, silly me. Here it is dutifully updated

Lorenzo Bercelli

python.vim.patch

Bram Moolenaar

unread,
Sep 18, 2013, 4:02:36 PM9/18/13
to Lorenzo Bercelli, vim...@vim.org, joha...@zellner.org
Your text suggests to set tabstop to 4, but the patch makes clear that
you only set softtabstop and shiftwidth to 4. That is OK. Tabstop
should be at its default of 8 to avoid trouble.

--
hundred-and-one symptoms of being an internet addict:
226. You sit down at the computer right after dinner and your spouse
says "See you in the morning."

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Lorenzo Bercelli

unread,
Sep 18, 2013, 6:12:17 PM9/18/13
to Bram Moolenaar, vim...@vim.org, joha...@zellner.org
Yes, I didn't explicitly set tabstop=8 because it's already default, should I ?

 
   Lorenzo

Marius Gedminas

unread,
Sep 20, 2013, 6:22:06 AM9/20/13
to vim...@googlegroups.com, Bram Moolenaar, vim...@vim.org, joha...@zellner.org
On Wed, Sep 18, 2013 at 10:12:17PM +0000, Lorenzo Bercelli wrote:
> Yes, I didn't explicitly set tabstop=8 because it's already default, should
> I ?

That may be a good idea. Python interprets ASCII TAB as being 8 spaces
wide, for the purposes of indentation:
http://docs.python.org/2/reference/lexical_analysis.html#indentation

Marius Gedminas
--
The difference between Microsoft and 'Jurassic Park':
In one, a mad businessman makes a lot of money with beasts that should be
extinct.
The other is a film.
signature.asc

Nikolay Pavlov

unread,
Sep 20, 2013, 1:28:38 PM9/20/13
to vim...@googlegroups.com, joha...@zellner.org, Bram Moolenaar, vim...@vim.org


On Sep 20, 2013 2:22 PM, "Marius Gedminas" <mar...@gedmin.as> wrote:
>
> On Wed, Sep 18, 2013 at 10:12:17PM +0000, Lorenzo Bercelli wrote:
> > Yes, I didn't explicitly set tabstop=8 because it's already default, should
> > I ?
>
> That may be a good idea.  Python interprets ASCII TAB as being 8 spaces
> wide, for the purposes of indentation:
> http://docs.python.org/2/reference/lexical_analysis.html#indentation

I do not think so. Using mixed tabs/spaces is highly discouraged even by vim syntax highlighting; and it is even a syntax error in python 3. If tabs are not mixed with spaces it does not matter how wide they are.

Lorenzo Bercelli

unread,
Sep 24, 2013, 1:28:12 PM9/24/13
to Bram Moolenaar, vim...@vim.org, joha...@zellner.org
The maintainer hasn't answered this email either. I'm sending you the patch again, assuming you approved it the last time.

 
   Lorenzo


On Wed, Sep 18, 2013 at 8:02 PM, Bram Moolenaar <Br...@moolenaar.net> wrote:
python.vim.patch

Bram Moolenaar

unread,
Sep 25, 2013, 7:53:24 AM9/25/13
to Lorenzo Bercelli, vim...@vim.org, joha...@zellner.org

Lorenzo Bercelli wrote:

> The maintainer hasn't answered this email either. I'm sending you the
> patch again, assuming you approved it the last time.

OK. Let's make it one line:

" As suggested by PEP8.
setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8

I'll also include the patch for keywordprg.


--
This sentence is not sure that it exists, but if it does, it will
certainly consider the possibility that other sentences exist.

Lorenzo Bercelli

unread,
Sep 25, 2013, 1:28:29 PM9/25/13
to Bram Moolenaar, vim...@vim.org, joha...@zellner.org
Thanks. Made it one line.

 
   Lorenzo
python.vim.patch
Reply all
Reply to author
Forward
0 new messages