After typing the bracket and enter, the next line will has 8 spaces indentation:
print conn.generate_url(
seconds,
'GET',
instead of 4:
print conn.generate_url(
seconds,
'GET',
My ~/.vimrc
: https://github.com/quantonganh/salt-states/blob/master/vim/vimrc.jinja2
Did I miss something?
Here's the list of my plugins:
├── ctrlp.vim
├── gundo.vim
├── jedi-vim
├── nerdtree
├── powerline
├── salt-vim
├── supertab
├── syntastic
├── ultisnips
├── vim-fugitive
├── vim-indent-guides
├── vim-surround
├── vim-yankstack
└── vundle
UPDATE Sat Apr 12 10:00:55 ICT 2014
I'm wondering that: is it follow PEP8 or not?
print conn.generate_url(
seconds,
'GET',
bucket,
key,
response_headers={
'response-content-type': 'application/octet-stream'
})
Continuation lines should align wrapped elements either vertically using Python's implicit line joining inside parentheses, brackets and braces, or using a hanging indent. When using a hanging indent the following considerations should be applied; there should be no arguments on the first line and further indentation should be used to clearly distinguish itself as a continuation line.
In a function, we will have something to distinguish with continuous lines, but here's just a print
, should it be 4 or 8 spaces?
What is PEP8's E128: continuation line under-indented for visual indent?
UPDATE Sat Apr 12 23:09:27 ICT 2014
Looks like jedi-vim
doesn't do anything with Python's indentation. So my question should be change to something like:
It's OK to add 8 spaces (2 indent levels) for the next line after bracket when defining a function:
# More indentation included to distinguish this from the rest.
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
but I only want to add 4 spaces (one indent level) when calling it:
# Extra indentation is not necessary.
foo = long_function_name(
var_one, var_two,
var_three, var_four)
How can I do it?
As you mentioned, PEP8's chapter on indentation suggests to add two indent levels instead of one before the arguments (when there is none on the first line) to distinguish it from the rest.
But it also adds that in cases where the extra indentation is not necessary, it's becomes optional. Your editor decided to add it, but according to PEP8, you have the choice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With