On 2017-05-04, Jacques Troussard wrote:
> Can anyone explain to me why when writing python code, vim is auto
> indenting after this variable assignment?
>
> .vimrc file setting for python file
> autocmd BufNewFile, BufRead *.py
> \ set tabstop=4
> \ set softtabstop=4
> \ set shiftwidth=4
> \ set textwidth=80
I don't know why Vim is autoindenting, unless you have 'autoindent'
set somewhere or you have filetype indenting enabled.
But, that autocmd is not going to work, if that's what it really is
and the above is not just a transcription error.
To start with, spaces are not allowed within the list of events. The
two events should be given as
BufNewFile,BufRead
You have told Vim to look for a BufNewFile event for a file named
BufRead.
Secondly, when you use \ to continue Vim statements, all the lines
in the statements are concatenated together as though they were on
one line. Vim sees your autocmd as the single line:
autocmd BufNewFile, BufRead *.py set tabstop=4 set softtabstop=4 set shiftwidth=4 set textwidth=80
There are two ways to fix that. One is to put the command
separator | between the set commands, as:
autocmd BufNewFile,BufRead *.py
\ set tabstop=4
\ | set softtabstop=4
\ | set shiftwidth=4
\ | set textwidth=80
The other is to put all those settings into one set command, as:
autocmd BufNewFile,BufRead *.py
\ set tabstop=4
\ softtabstop=4
\ shiftwidth=4
\ textwidth=80
See also:
:help line-continuation
:help :bar
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment