Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions indent/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ function! s:indent_like_opening_paren(lnum)
return res + s:sw()
endif
endif

" Indent by one level with colon on previous line (dictionary keys).
if getline(a:lnum-1) =~# ':\s*$'
let res = res + s:sw()
endif

return res
endfunction

Expand Down
16 changes: 16 additions & 0 deletions spec/indent/indent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@
end
end

describe "after a dictionary key" do
before { vim.feedkeys 'imydict = {"12345": ' }

it "indents to opening paren + shiftwidth" do
vim.feedkeys '\<CR>'
indent.should == 10 + shiftwidth
end
it "on a new line indents to opening paren + shiftwidth" do
vim.feedkeys '123,\<CR>"4567": '
indent.should == 10
vim.feedkeys '\<CR>'
indent.should == 10 + shiftwidth
end
end


describe "when using gq to reindent a '(' that is" do
before { vim.feedkeys 'itest(' }
it "something and has a string without spaces at the end" do
Expand Down