From 14f4daaacca9e36a5281e54c105ca5d90fc70c87 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 7 Jul 2018 01:00:43 +1200 Subject: Get 'shiftwidth' in Vim Perl indent portably From `:help shiftwidth()`: > Returns the effective value of 'shiftwidth'. This is the 'shiftwidth' > value unless it is zero, in which case it is the 'tabstop' value. This > function was introduced with patch 7.3.694 in 2012, everybody should > have it by now. I'd like my stuff to work on older versions, though, and it's not hard to make it work. --- vim/indent/perl.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'vim/indent') diff --git a/vim/indent/perl.vim b/vim/indent/perl.vim index ee7028ec..edb91028 100644 --- a/vim/indent/perl.vim +++ b/vim/indent/perl.vim @@ -22,7 +22,9 @@ function! GetPerlIndent() let l:pi = indent(l:pn) " Get value of 'shiftwidth' - let l:sw = shiftwidth() + let l:sw = exists('*shiftwidth') + \ ? shiftwidth() + \ : &shiftwidth " Don't touch comments if l:pl =~# '^\s*#' -- cgit v1.2.3