Skip to content

Commit

Permalink
I want to be able to cuddle opening braces and have the indent level
Browse files Browse the repository at this point in the history
only increase by one shift-width.

By setting "let g:PerlCuddleIndent=1" you can allow this behavior

eg ("|" represents the cursor):

$foo = [{
    |
}]
  • Loading branch information
neybar committed Sep 1, 2016
1 parent 91163b5 commit 8ac06b4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion indent/perl.vim
Expand Up @@ -19,6 +19,13 @@
" (The following probably needs modifying the perl syntax file)
" - qw() lists
" - Heredocs with terminators that don't match \I\i*
"
" If multiple opening braces are on the same line, then
" normal behavior is to indent over one shift width per
" opening brace.
"
" If you want to collapse the indents for cuddled braces then:
" let g:PerlCuddleIndent = 1

" Only load this indent file when no other was loaded.
if exists("b:did_indent")
Expand Down Expand Up @@ -139,7 +146,12 @@ function! GetPerlIndent()
let ind = ind - &sw
endif
endif
let bracepos = match(line, braceclass, bracepos + 1)

if exists('g:PerlCuddleIndent') && g:PerlCuddleIndent
let bracepos = -1
else
let bracepos = match(line, braceclass, bracepos + 1)
endif
endwhile
let bracepos = matchend(cline, '^\s*[])}]')
if bracepos != -1
Expand Down

0 comments on commit 8ac06b4

Please sign in to comment.