aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/perl.vim
blob: ca9b299069e681d4d960ae549750105298088928 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
" Quick-and-dirty version number bumper
function! perl#BumpVersion(major) abort
  let l:view = winsaveview()
  let l:search = @/
  let l:li = search('\C^our \$VERSION\s*=')
  if !l:li
    echomsg 'No version number declaration found'
    return
  endif
  if a:major
    silent execute "normal! /[0-9]\<CR>\<C-A>"
    echomsg 'Major version bumped: '.getline('.')
  else
    silent execute "normal! $?[0-9]\<CR>\<C-A>"
    echomsg 'Minor version bumped: '.getline('.')
  endif
  let @/ = l:search
  call winrestview(l:view)
endfunction

" Explanatory wrappers
function! perl#BumpVersionMinor() abort
  call perl#BumpVersion(0)
endfunction

function! perl#BumpVersionMajor() abort
  call perl#BumpVersion(1)
endfunction